]> git.ipfire.org Git - people/teissler/ipfire-2.x.git/blobdiff - config/cfgroot/header.pl
Remove /var/ipfire/firebuild.
[people/teissler/ipfire-2.x.git] / config / cfgroot / header.pl
index 552bb20ec409f9ab01cf3bf52651e3ddf57f2d74..299d7664599290d5a7a4c828746d58c820d0d633 100644 (file)
@@ -9,27 +9,18 @@
 # Copyright (c) 2002/08/23 Mark Wormgoor <mark@wormgoor.com> validfqdn()
 # Copyright (c) 2003/09/11 Darren Critchley <darrenc@telus.net> srtarray()
 #
-# $Id: header.pl,v 1.34.2.39 2004/11/26 15:51:27 alanh Exp $
-#
 package Header;
 
 use CGI();
+use HTML::Entities();
 use Socket;
 use Time::Local;
 
 $|=1; # line buffering
 
-sub get_version() {
-    my $read_ver = `cat /etc/ipfire-release`;
-    if ($read_ver =~ /^$/) {
-       return "IPFire (unknown version)";
-    }
-    return $read_ver;
-}
-
-$Header::version = get_version();
 $Header::revision = 'final';
 $Header::swroot = '/var/ipfire';
+$Header::graphdir='/srv/web/ipfire/html/graphs';
 $Header::pagecolour = '#ffffff';
 #$Header::tablecolour = '#a0a0a0';
 $Header::tablecolour = '#FFFFFF';
@@ -43,6 +34,7 @@ $Header::colourorange = '#FF9933';
 $Header::colouryellow = '#FFFF00';
 $Header::colourgreen = '#339933';
 $Header::colourblue = '#333399';
+$Header::colourovpn = '#339999';
 $Header::colourfw = '#000000';
 $Header::colourvpn = '#990099';
 $Header::colourerr = '#FF0000';
@@ -53,18 +45,17 @@ my $menu = \%menuhash;
 %settings = ();
 %ethsettings = ();
 @URI = ();
-$Header::supported=0;
 
 ### Make sure this is an SSL request
 if ($ENV{'SERVER_ADDR'} && $ENV{'HTTPS'} ne 'on') {
     print "Status: 302 Moved\r\n";
-    print "Location: https://$ENV{'SERVER_ADDR'}:10443/$ENV{'PATH_INFO'}\r\n\r\n";
+    print "Location: https://$ENV{'SERVER_ADDR'}:444/$ENV{'PATH_INFO'}\r\n\r\n";
     exit 0;
 }
 
 ### Initialize environment
-&readhash("${swroot}/main/settings", \%settings);
-&readhash("${swroot}/ethernet/settings", \%ethsettings);
+&General::readhash("${swroot}/main/settings", \%settings);
+&General::readhash("${swroot}/ethernet/settings", \%ethsettings);
 $language = $settings{'LANGUAGE'};
 $hostname = $settings{'HOSTNAME'};
 $hostnameintitle = 0;
@@ -97,26 +88,26 @@ if ( -d "/var/ipfire/langs/${language}/" ) {
     };
 };
 
-
 require "${swroot}/langs/en.pl";
 require "${swroot}/langs/${language}.pl";
+eval `/bin/cat /srv/web/ipfire/html/themes/$settings{'THEME'}/include/functions.pl`;
 
 sub orange_used () {
-    if ($ethsettings{'CONFIG_TYPE'} =~ /^[1357]$/) {
+    if ($ethsettings{'CONFIG_TYPE'} =~ /^[24]$/) {
        return 1;
     }
     return 0;
 }
 
 sub blue_used () {
-    if ($ethsettings{'CONFIG_TYPE'} =~ /^[4567]$/) {
+    if ($ethsettings{'CONFIG_TYPE'} =~ /^[34]$/) {
        return 1;
     }
     return 0;
 }
 
 sub is_modem {
-    if ($ethsettings{'CONFIG_TYPE'} =~ /^[0145]$/) {
+    if ($ethsettings{'CONFIG_TYPE'} =~ /^[0]$/) {
        return 1;
     }
     return 0;
@@ -124,410 +115,48 @@ sub is_modem {
 
 ### Initialize menu
 sub genmenu {
+
     my %subsystemhash = ();
     my $subsystem = \%subsystemhash;
 
-    $subsystem->{'01.home'} = {
-                             'caption' => $tr{'alt home'},
-                             'uri' => '/cgi-bin/index.cgi',
-                             'title' => "$tr{'alt home'}",
-                             'enabled' => 1,
-                             };
-    $subsystem->{'02.netwizard'} = {
-                                  'caption' => $tr{'network configuration'},
-                                  'uri' => '/cgi-bin/netwizard.cgi',
-                                  'title' => "$tr{'network configuration'}",
-                                  'enabled' => 1,
-                                  };
-    $subsystem->{'03.updates'} = {
-                                'caption' => $tr{'updates'},
-                                'uri' => '/cgi-bin/updates.cgi',
-                                'title' => "$tr{'updates'}",
-                                'enabled' => 0,
-                                };
-    $subsystem->{'04.passwords'} = {
-                                  'caption' => $tr{'sspasswords'},
-                                  'uri' => '/cgi-bin/changepw.cgi',
-                                  'title' => "$tr{'sspasswords'}",
-                                  'enabled' => 1,
-                                  };
-    $subsystem->{'05.ssh'} = {
-                            'caption' => $tr{'ssh access'},
-                            'uri' => '/cgi-bin/remote.cgi',
-                            'title' => "$tr{'ssh access'}",
-                            'enabled' => 1,
-                            };
-    $subsystem->{'06.gui'} = {
-                             'caption' => $tr{'gui settings'},
-                             'uri' => '/cgi-bin/gui.cgi',
-                             'title' => "$tr{'gui settings'}",
-                             'enabled' => 1,
-                             };
-    $subsystem->{'07.backup'} = {
-                               'caption' => $tr{'backup'},
-                               'uri' => '/cgi-bin/backup.cgi',
-                               'title' => "$tr{'backup'} / $tr{'restore'}",
-                               'enabled' => 1,
-                               };
-    $subsystem->{'08.shutdown'} = {
-                                 'caption' => $tr{'shutdown'},
-                                 'uri' => '/cgi-bin/shutdown.cgi',
-                                 'title' => "$tr{'shutdown'} / $tr{'reboot'}",
-                                 'enabled' => 1,
-                                 };
-    $subsystem->{'09.credits'} = {
-                                 'caption' => $tr{'credits'},
-                                 'uri' => '/cgi-bin/credits.cgi',
-                                 'title' => "$tr{'credits'}",
-                                 'enabled' => 1,
-                                 };
-
     my %substatushash = ();
     my $substatus = \%substatushash;
-    $substatus->{'01.systemstatus'} = {
-                                'caption' => $tr{'sssystem status'},
-                                'uri' => '/cgi-bin/status.cgi',
-                                'title' => "$tr{'system status information'}",
-                                'enabled' => 1,
-                                };
-    $substatus->{'02.networkstatus'} = {
-                                 'caption' => $tr{'ssnetwork status'},
-                                 'uri' => '/cgi-bin/netstatus.cgi',
-                                 'title' => "$tr{'network status information'}",
-                                 'enabled' => 1,
-                                 };
-    $substatus->{'03.systemgraphs'} = {
-                                      'caption' => $tr{'system graphs'},
-                                      'uri' => '/cgi-bin/graphs.cgi',
-                                      'novars' => 1,
-                                      'title' => "$tr{'system graphs'}",
-                                      'enabled' => 1,
-                                      };
-    $substatus->{'04.trafficgraphs'} = {
-                                       'caption' => $tr{'sstraffic graphs'},
-                                       'uri' => '/cgi-bin/graphs.cgi',
-                                       'vars' => 'graph=network',
-                                       'title' => "$tr{'network traffic graphs'}",
-                                       'enabled' => 1,
-                                       };
-    $substatus->{'05.proxygraphs'} = {
-                                     'caption' => $tr{'ssproxy graphs'},
-                                     'uri' => '/cgi-bin/proxygraphs.cgi',
-                                     'title' => "$tr{'proxy access graphs'}",
-                                     'enabled' => 1,
-                                     };
-    $substatus->{'06.connections'} = {
-                                     'caption' => $tr{'connections'},
-                                     'uri' => '/cgi-bin/connections.cgi',
-                                     'title' => "$tr{'connections'}",
-                                     'enabled' => 1,
-                                     };
-    $substatus->{'99.iptfilters'} = {
-                                     'caption' => $tr{'iptfilters iptable rules'},
-                                     'uri' => '/cgi-bin/iptfilters.cgi',
-                                     'title' => "$tr{'iptfilters iptable rules'}",
-                                     'enabled' => 1,
-                                     };
 
     my %subnetworkhash = ();
     my $subnetwork = \%subnetworkhash;
 
-    $subnetwork->{'01.dialup'} = {
-                                 'caption' => $tr{'alt dialup'},
-                                 'uri' => '/cgi-bin/pppsetup.cgi',
-                                 'title' => "$tr{'dialup settings'}",
-                                 'enabled' => 0,
-                                 };
-    $subnetwork->{'02.hosts'} = {
-                                'caption' => $tr{'edit hosts'},
-                                'uri' => '/cgi-bin/hosts.cgi',
-                                'title' => "$tr{'host configuration'}",
-                                'enabled' => 1,
-                                };
-    $subnetwork->{'03.upload'} = {
-                                 'caption' => $tr{'upload'},
-                                 'uri' => '/cgi-bin/upload.cgi',
-                                 'title' => "$tr{'firmware upload'}",
-                                 'enabled' => 0,
-                                 };
-    $subnetwork->{'04.aliases'} = {
-                                 'caption' => $tr{'aliases'},
-                                 'uri' => '/cgi-bin/aliases.cgi',
-                                 'title' => "$tr{'external aliases configuration'}",
-                                 'enabled' => 1,
-                                 };
-
-
     my %subserviceshash = ();
     my $subservices = \%subserviceshash;
 
-    $subservices->{'01.dhcp'} = {
-                                'caption' => $tr{'dhcp server'},
-                                'uri' => '/cgi-bin/dhcp.cgi',
-                                'title' => "$tr{'dhcp configuration'}",
-                                'enabled' => 1,
-                                };
-    $subservices->{'02.dyndns'} = {
-                                  'caption' => $tr{'dynamic dns'},
-                                  'uri' => '/cgi-bin/ddns.cgi',
-                                  'title' => "$tr{'dynamic dns client'}",
-                                  'enabled' => 1,
-                                };
-    $subservices->{'03.time'} = {
-                                  'caption' => $tr{'time server'},
-                                  'uri' => '/cgi-bin/time.cgi',
-                                  'title' => "$tr{'time server'}",
-                                  'enabled' => 1,
-                                };
-    $subservices->{'04.shaping'} = {
-                                   'caption' => $tr{'traffic shaping'},
-                                   'uri' => '/cgi-bin/shaping.cgi',
-                                   'title' => "$tr{'traffic shaping settings'}",
-                                   'enabled' => 1,
-                                   };
-    $subservices->{'05.ids'} = {'caption' => $tr{'intrusion detection'},
-                               'enabled' => 1,
-                               'uri' => '/cgi-bin/ids.cgi',
-                               'title' => "$tr{'intrusion detection system'} (Snort)",
-                               };
-
-
     my %subfirewallhash = ();
     my $subfirewall = \%subfirewallhash;
 
-    
-    $subfirewall->{'01.dnat'} = {
-                                'caption' => $tr{'ssport forwarding'},
-                                'uri' => '/cgi-bin/portfw.cgi',
-                                'title' => "$tr{'port forwarding configuration'}",
-                                'enabled' => 1,
-                                };
-    $subfirewall->{'02.xtaccess'} = {
-                                'caption' => $tr{'external access'},
-                                'uri' => '/cgi-bin/xtaccess.cgi',
-                                'title' => "$tr{'external access configuration'}",
-                                'enabled' => 1,
-                                };
-    $subfirewall->{'03.dmz'} = {
-                               'caption' => $tr{'ssdmz pinholes'},
-                               'uri' => '/cgi-bin/dmzholes.cgi',
-                               'title' => "$tr{'dmz pinhole configuration'}",
-                               'enabled' => 1,
-                                };
-    $subfirewall->{'04.outgoing'} = {
-                                    'caption' => $tr{'outgoing firewall'},
-                                    'uri' => '/cgi-bin/outgoingfw.cgi',
-                                    'title' => "$tr{'outgoing firewall'}",
-                                    'enabled' => 1,
-                                    };
-    
-
-
-    my %subhttphash = ();
-    my $subhttp = \%subhttphash;
-    $subhttp->{'01.proxy'} = {
-                             'caption' => $tr{'proxy'},
-                             'uri' => '/cgi-bin/advproxy.cgi',
-                             'title' => "HTTP: $tr{'web proxy configuration'}",
-                             'enabled' => 1,
-                             };
-    $subhttp->{'02.contentfilter'} = {
-                                     'caption' => $tr{'content filter'},
-                                     'uri' => '/cgi-bin/dansguardian.cgi',
-                                     'title' => "HTTP: $tr{'content filter'}",
-                                     'enabled' => 1,
-                                     };
-    $subhttp->{'03.antivirus'} = {
-                                 'caption' => $tr{'antivirus'},
-                                 'uri' => '/cgi-bin/httpantivirus.cgi',
-                                 'title' => "HTTP: $tr{'antivirus'}",
-                                 'enabled' => 1,
-                                 };
-     $subhttp->{'04.proxymanagment'} = {
-                                   'caption' => $tr{'DS Managment'},
-                                   'uri' => '/cgi-bin/proxygm.cgi',
-                                   'title' => "HTTP: $tr{'DS Managment'}",
-                                   'enabled' => 1,
-                                   };
-     $subhttp->{'05.activatedgroups'} = {
-                                   'caption' => $tr{'activated Groups'},
-                                   'uri' => '/cgi-bin/proxyag.cgi',
-                                   'title' => "HTTP: $tr{'activated Groups'}",
-                                   'enabled' => 1,
-                                   };
-     $subhttp->{'06.advancedproxy'} = {
-                                   'caption' => $tr{'Proxy Advanced'},
-                                   'uri' => '/cgi-bin/proxyad.cgi',
-                                   'title' => "HTTP: $tr{'Proxy Advanced'}",
-                                   'enabled' => 1,
-                                   };
-
-
-    my %subproxyhash = ();
-    my $subproxy = \%subproxyhash;
-
-    $subproxy->{'01.http'} = {'caption' => $tr{'HTTP'},
-                             'enabled' => 1,
-                             'subMenu' => $subhttp
-                             };
-    $subproxy->{'02.ftp'} = {'caption' => 'FTP',
-                             'enabled' => 1,
-                             'subMenu' => $subftp
-                             };
-
-
-
-    my %subopenvpnhash = ();
-    my $subopenvpn = \%subopenvpnhash;
-    $subopenvpn->{'01.server'} = {'caption' => $tr{'openvpn'},
-                                 'uri' => '/cgi-bin/openvpn.cgi',
-                                 'title' => "$tr{'virtual private networking'}",
-                                 'enabled' => 1,
-                                 };
-    $subopenvpn->{'02.client'} = {'caption' => $tr{'openvpnclient'},
-                                 'uri' => '/cgi-bin/openvpnclient.cgi',
-                                 'title' => "$tr{'virtual private networking'}",
-                                 'enabled' => 1,
-                                 };
-
-    my %subvpnhash = ();
-    my $subvpn = \%subvpnhash;
-
-    $subvpn->{'01.openvpn'} = {'caption' => $tr{'openvpn'},
-                              'subMenu' => $subopenvpn,
-                              'enabled' => 1,
-                          };
-    $subvpn->{'02.ipsec'} = {'caption' => $tr{'ipsec'},
-                            'uri' => '/cgi-bin/vpnmain.cgi',
-                            'title' => "$tr{'virtual private networking'}",
-                            'enabled' => 1,
-                        };
+    my %subipfirehash = ();
+    my $subipfire = \%subipfirehash;
 
     my %sublogshash = ();
     my $sublogs = \%sublogshash;
 
-    $sublogs->{'01.summary'} = {'caption' => $tr{'log summary'},
-                                'uri' => '/cgi-bin/logs.cgi/summary.dat',
-                                'title' => "$tr{'log summary'}",
-                                'enabled' => 1
-                                };
-    $sublogs->{'02.settings'} = {'caption' => $tr{'log settings'},
-                                'uri' => '/cgi-bin/logs.cgi/config.dat',
-                                'title' => "$tr{'log settings'}",
-                                'enabled' => 1
-                                };
-    $sublogs->{'03.proxy'} = {'caption' => $tr{'proxy logs'},
-                                'uri' => '/cgi-bin/logs.cgi/proxylog.dat',
-                                'title' => "$tr{'proxy log viewer'}",
-                                'enabled' => 1
-                                };
-    $sublogs->{'04.firewall'} = {'caption' => $tr{'firewall logs'},
-                                'uri' => '/cgi-bin/logs.cgi/firewalllog.dat',
-                                'title' => "$tr{'firewall log viewer'}",
-                                'enabled' => 1
-                                };
-    $sublogs->{'05.ids'} = {'caption' => $tr{'ids logs'},
-                           'uri' => '/cgi-bin/logs.cgi/ids.dat',
-                           'title' => "$tr{'intrusion detection system log viewer'}",
-                           'enabled' => 1
-                           };
-    $sublogs->{'06.contentfilter'} = {'caption' => $tr{'content filter logs'},
-                                     'uri' => '/cgi-bin/logs.cgi/dansguardian.dat',
-                                     'title' => "$tr{'content filter log viewer'}",
-                                     'enabled' => 1
-                                     };
-    $sublogs->{'07.urlfilter'} = {
-                                     'caption' => $tr{'urlfilter log'},
-                                     'uri' => '/cgi-bin/logs.cgi/urlfilter.dat',
-                                     'title' => "$tr{'urlfilter log'}",
-                                     'enabled' => 1,
-                                      };
-    $sublogs->{'08.openvpn'} = {'caption' => $tr{'openvpn log'},
-                                     'uri' => '/cgi-bin/logs.cgi/openvpn.dat',
-                                     'title' => "$tr{'openvpn log'}",
-                                     'enabled' => 1
-                                     };
-    $sublogs->{'09.system'} = {'caption' => $tr{'system logs'},
-                                     'uri' => '/cgi-bin/logs.cgi/log.dat',
-                                     'title' => "$tr{'system log viewer'}",
-                                     'enabled' => 1
-                                     };
-    $sublogs->{'10.userlog'} = {'caption' => $tr{'user proxy logs'},
-                                      'uri' => '/cgi-bin/logs.cgi/userlog.dat',
-                                      'title' => "$tr{'user log viewer'}",
-                                      'enabled' => 1
-                                       };
+    eval `/bin/cat /var/ipfire/menu.d/*.menu`;
+    eval `/bin/cat /var/ipfire/menu.d/*.main`;
 
-    my %subipfirehash = ();
-    my $subipfire = \%subipfirehash;
-    $subipfire->{'01.pakfire'} = {'caption' => $tr{'pakfire'},
-                                 'uri' => '/cgi-bin/pakfire.cgi',
-                                 'title' => "$tr{'paketmanager'}",
-                                 'enabled' => 1,
-                                 };
-    $subipfire->{'02.samba'} = {'caption' => $tr{'samba'},
-                                 'uri' => '/cgi-bin/samba.cgi',
-                                 'title' => "$tr{'samba'}",
-                                 'enabled' => 1,
-                                 };
-
-
-
-    $menu->{'01.system'} = {'caption' => $tr{'alt system'},
-                           'enabled' => 1,
-                           'subMenu' => $subsystem
-                           };
-    $menu->{'02.status'} = {'caption' => $tr{'status'},
-                           'enabled' => 1,
-                           'subMenu' => $substatus
-                           };
-    $menu->{'03.network'} = {'caption' => $tr{'network'},
-                            'enabled' => 1,
-                            'subMenu' => $subnetwork
-                            };
-    $menu->{'04.services'} = {'caption' => $tr{'alt services'},
-                             'enabled' => 1,
-                             'subMenu' => $subservices
-                             };
-    $menu->{'05.firewall'} = {'caption' => $tr{'firewall'},
-                             'enabled' => 1,
-                             'subMenu' => $subfirewall
-                             };
-    $menu->{'06.proxy'} = {'caption' => $tr{'alt proxy'},
-                          'enabled' => 1,
-                          'subMenu' => $subproxy
-                          };
-    $menu->{'07.vpn'} = {'caption' => 'VPN',
-                        'enabled' => 1,
-                        'subMenu' => $subvpn
-                        };
-    $menu->{'08.logs'} = {'caption' => $tr{'alt logs'},
-                         'enabled' => 1,
-                         'subMenu' => $sublogs
-                         };
-    $menu->{'09.ipfire'} = {'caption' => 'IPFire'},
-                         'enabled' => 1,
-                         'subMenu' => $subipfire
-                         };
-
-
-
-    if (! blue_used() && ! orange_used()) {
-       $menu->{'05.firewall'}{'subMenu'}->{'03.dmz'}{'enabled'} = 0;
+    if (! blue_used()) {
+       $menu->{'05.firewall'}{'subMenu'}->{'60.wireless'}{'enabled'} = 0;
+    }
+    if ( $ethsettings{'CONFIG_TYPE'} =~ /^(1|2|3|4)$/ && $ethsettings{'RED_TYPE'} eq 'STATIC' ) {
+       $menu->{'03.network'}{'subMenu'}->{'70.aliases'}{'enabled'} = 1;
     }
-    if (-e '/etc/FLASH') {
-       $menu{'06.proxy'}{'subMenu'}->{'01.http'}{'subMenu'}->{'01.proxy'}{'enabled'} = 0;  #disable squid
-       $menu{'04.services'}{'subMenu'}->{'05.ids'}{'enabled'} = 0;  #disable ids
-       $menu{'08.logs'}{'subMenu'}->{'05.ids'}{'enabled'} = 0;  #disable ids
+
+    if (&General::RedIsWireless()) {
+        $menu->{'01.system'}{'subMenu'}->{'21.wlan'}{'enabled'} = 1;
     }
 }
 
 sub showhttpheaders
 {
-       print "Pragma: no-cache\n";
-       print "Cache-control: no-cache\n";
+       print "Cache-control: private\n";
        print "Connection: close\n";
-       print "Content-type: text/html\n\n";
+       print "Content-type: text/html; charset=UTF-8\n\n";
 }
 
 sub is_menu_visible($) {
@@ -616,360 +245,6 @@ sub gettitle($) {
     return '';
 }
 
-
-sub showmenu() {
-    print <<EOF
-  <div id="menu-top">
-    <ul>
-EOF
-;
-    foreach my $k1 ( sort keys %$menu ) {
-       if (! $menu->{$k1}{'enabled'}) {
-           next;
-       }
-
-       my $link = getlink($menu->{$k1});
-       if ($link eq '') {
-           next;
-       }
-       if (! is_menu_visible($link)) {
-           next;
-       }
-       if ($menu->{$k1}->{'selected'}) {
-           print '<li class="selected">';
-       } else {
-           print '<li>';
-       }
-
-       print <<EOF
-    <div class="rcorner">
-      <a href="$link">$menu->{$k1}{'caption'}</a>
-    </div>
-  </li>
-EOF
-;
-    }
-
-    print <<EOF
-    </ul>
-  </div>
-EOF
-;    
-}
-
-sub getselected($) {
-    my $root = shift;
-    if (!$root) {
-       return 0;
-    }
-
-    foreach my $item (%$root) {
-       if ($root->{$item}{'selected'}) {
-           return $root->{$item};
-       }
-    }
-}
-
-sub showsubsection($$) {
-    my $root = shift;
-    my $id = shift;
-    if ($id eq '') {
-       $id = 'menu-left';
-    }
-
-    if (! $root) {
-       return;
-    }
-    my $selected = getselected($root);
-    if (! $selected) {
-       return;
-    }
-    my $submenus = $selected->{'subMenu'};
-    if (! $submenus) {
-       return;
-    }
-
-    print <<EOF
-  <div id="$id">
-    <ul>
-EOF
-;
-    foreach my $item (sort keys %$submenus) {
-       my $hash = $submenus->{$item};
-       if (! $hash->{'enabled'}) {
-           next;
-       }
-
-       my $link = getlink($hash);
-       if ($link eq '') {
-           next;
-       }
-       if (! is_menu_visible($link)) {
-           next;
-       }
-       if ($hash->{'selected'}) {
-           print '<li class="selected">';
-       } else {
-           print '<li>';
-       }
-
-       print <<EOF
-      <a href="$link">$hash->{'caption'}</a>
-  </li>
-EOF
-;
-    }
-
-    print <<EOF
-    </ul>
-  </div>
-EOF
-;    
-
-}
-
-
-sub showsubsubsection($) {
-    my $root = shift;
-    if (!$root) {
-       return;
-    }
-    my $selected = getselected($root);
-    if (! $selected) {
-       return
-    }
-    if (! $selected->{'subMenu'}) {
-       return
-    }
-
-    showsubsection($selected->{'subMenu'}, 'menu-subtop');
-}
-
-
-sub get_helpuri() {
-    my $helpfile = '';
-    if ($URI[0] =~ /.*\/([^\/]+)\.cgi/) {
-       $helpfile = $1;
-    } else {
-       return '';
-    }
-    $helpfile .= '.help.html';
-
-    my $helpuri = '/doc/'.$language.'/'.$helpfile;
-    if (! -e $ENV{'DOCUMENT_ROOT'}.$helpuri) {
-       return '';
-    }
-    return $helpuri;
-}
-
-
-sub openpage {
-    my $title = shift;
-    my $boh = shift;
-    my $extrahead = shift;
-
-    @URI=split ('\?',  $ENV{'REQUEST_URI'} );
-    &readhash("${swroot}/main/settings", \%settings);
-    &genmenu();
-
-    my $h2 = gettitle($menu);
-    my $helpuri = get_helpuri();
-
-    $title = "IPFire - $title";
-    if ($settings{'WINDOWWITHHOSTNAME'} eq 'on') {
-        $title =  "$settings{'HOSTNAME'}.$settings{'DOMAINNAME'} - $title"; 
-    }
-
-    print <<END
-<!DOCTYPE html 
-     PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
-     "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
-
-<html>
-  <head>
-  <title>$title</title>
-
-    $extrahead
-    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
-    <link rel="shortcut icon" href="/favicon.ico" />
-    <style type="text/css">\@import url(/include/style.css);</style>
-    <style type="text/css">\@import url(/include/menu.css);</style>
-    <style type="text/css">\@import url(/include/content.css);</style>
-
-    <script language="javascript" type="text/javascript">
-      
-        function swapVisibility(id) {
-            el = document.getElementById(id);
-           if(el.style.display != 'block') {
-               el.style.display = 'block'
-           }
-           else {
-               el.style.display = 'none'
-           }
-        }
-    </script>
-
-  </head>
-  <body>
-<!-- IPFIRE HEADER -->
-
-<div id="main">
-
-<div id="header">
-       <img id="logo-product" src="/images/logo_ipfire.gif">
-   <div id="header-icons">
-END
-;
-
-    if ($helpuri ne '') {
-       print <<END
-           <a href="$helpuri" target="_blank"><img border="0" src="/images/help.gif"></a>
-END
-;
-    } else {
-       print '<img src="/images/help.gif">';
-    }
-
-print <<END
-   </div>
-</div>
-
-END
-;
-
-    &showmenu();
-
-print <<END
-<div id="content">
-  <table width="90%">
-    <tr>
-      <td valign="top">
-END
-;
-       
-    &showsubsection($menu);
-
-    print <<END
-
-      </td>
-        <td width="100%" valign="top">
-        <div id="page-content">
-            <h2>$h2</h2>
-END
-    ;
-    
-    &showsubsubsection($menu);
-
-    eval {
-       require 'ipfire-network.pl';
-       $supported = check_support();
-       warn_unsupported($supported);
-    };
-}
-
-sub closepage () {
-    my $status = &connectionstatus();
-    $uptime = `/usr/bin/uptime`;
-       
-    print <<END
-         <div align="center">
-            <p>
-             <div style="font-size: 9px"><b>Status:</b> $status <b>Uptime:</b>$uptime</div>
-            </p>
-            <p><a href="http://www.ipfire.org">IPFire</a> $version (c)</p>
-          </div>
-       </body>
-       <meta http-equiv="Page-Enter" content="blendTrans(Duration=1.0,Transition=12)">
-       <meta http-equiv="Page-Exit" content="blendTrans(Duration=1.0,Transition=12)">
-</html>
-END
-;
-}
-
-sub openbigbox
-{
-    my $width = $_[0];
-    my $align = $_[1];
-    my $sideimg = $_[2];
-
-    if ($errormessage) {
-       $bgcolor = "style='background-color: $colourerr;'";
-    } else {
-       $bgcolor = '';
-    }
-}
-
-sub closebigbox
-{
-#      print "</td></tr></table></td></tr></table>\n" 
-}
-
-sub openbox
-{
-       $width = $_[0];
-       $align = $_[1];
-       $caption = $_[2];
-
-       if ($caption) { print "<h3>$caption</h3>\n"; } else { print "&nbsp;"; }
-       
-       print "<table class=\"list\"><tr><td align=\"$align\">\n";
-}
-
-sub closebox
-{
-       print "</td></tr></table><br><br>";
-}
-
-sub writehash
-{
-       my $filename = $_[0];
-       my $hash = $_[1];
-       
-       # write cgi vars to the file.
-       open(FILE, ">${filename}") or die "Unable to write file $filename";
-       flock FILE, 2;
-       foreach $var (keys %$hash) 
-       {
-               $val = $hash->{$var};
-               # Darren Critchley Jan 17, 2003 added the following because when submitting with a graphic, the x and y
-               # location of the mouse are submitted as well, this was being written to the settings file causing
-               # some serious grief! This skips the variable.x and variable.y
-               if (!($var =~ /(.x|.y)$/)) {
-                       if ($val =~ / /) {
-                               $val = "\'$val\'"; }
-                       if (!($var =~ /^ACTION/)) {
-                               print FILE "${var}=${val}\n"; }
-               }
-       }
-       close FILE;
-}
-
-sub readhash
-{
-       my $filename = $_[0];
-       my $hash = $_[1];
-       my ($var, $val);
-
-       open(FILE, $filename) or die "Unable to read file $filename";
-       
-       while (<FILE>)
-       {
-               chop;
-               ($var, $val) = split /=/, $_, 2;
-               if ($var)
-               {
-                       $val =~ s/^\'//g;
-                       $val =~ s/\'$//g;
-
-                       # Untaint variables read from hash
-                       $var =~ /([A-Za-z0-9_-]*)/;        $var = $1;
-                       $val =~ /([\w\W]*)/; $val = $1;
-                       $hash->{$var} = $val;
-               }
-       }
-       close FILE;
-}
-
 sub getcgihash {
        my ($hash, $params) = @_;
        my $cgi = CGI->new ();
@@ -1003,235 +278,6 @@ sub getcgihash {
        return;
 }
 
-sub log
-{
-       my $logmessage = $_[0];
-       $logmessage =~ /([\w\W]*)/;
-       $logmessage = $1;
-       system('/usr/bin/logger', '-t', 'ipfire', $logmessage);
-}
-
-sub age
-{
-       my ($dev, $ino, $mode, $nlink, $uid, $gid, $rdev, $size,
-               $atime, $mtime, $ctime, $blksize, $blocks) = stat $_[0];
-       my $now = time;
-
-       my $totalsecs = $now - $mtime;
-       my $days = int($totalsecs / 86400);
-       my $totalhours = int($totalsecs / 3600);
-       my $hours = $totalhours % 24;
-       my $totalmins = int($totalsecs / 60);
-       my $mins = $totalmins % 60;
-       my $secs = $totalsecs % 60;
-
-       return "${days}d ${hours}h ${mins}m ${secs}s";
-}
-
-sub validip
-{
-       my $ip = $_[0];
-
-       if (!($ip =~ /^(\d+)\.(\d+)\.(\d+)\.(\d+)$/)) {
-               return 0; }
-       else 
-       {
-               @octets = ($1, $2, $3, $4);
-               foreach $_ (@octets)
-               {
-                       if (/^0./) {
-                               return 0; }
-                       if ($_ < 0 || $_ > 255) {
-                               return 0; }
-               }
-               return 1;
-       }
-}
-
-sub validmask
-{
-       my $mask = $_[0];
-
-       # secord part an ip?
-       if (&validip($mask)) {
-               return 1; }
-       # second part a number?
-       if (/^0/) {
-               return 0; }
-       if (!($mask =~ /^\d+$/)) {
-               return 0; }
-       if ($mask >= 0 && $mask <= 32) {
-               return 1; }
-       return 0;
-}
-
-sub validipormask
-{
-       my $ipormask = $_[0];
-
-       # see if it is a IP only.
-       if (&validip($ipormask)) {
-               return 1; }
-       # split it into number and mask.
-       if (!($ipormask =~ /^(.*?)\/(.*?)$/)) {
-               return 0; }
-       $ip = $1;
-       $mask = $2;
-       # first part not a ip?
-       if (!(&validip($ip))) {
-               return 0; }
-       return &validmask($mask);
-}
-
-sub validipandmask
-{
-       my $ipandmask = $_[0];
-
-       # split it into number and mask.
-       if (!($ipandmask =~ /^(.*?)\/(.*?)$/)) {
-               return 0; }
-       $ip = $1;
-       $mask = $2;
-       # first part not a ip?
-       if (!(&validip($ip))) {
-               return 0; }
-       return &validmask($mask);
-}
-
-sub validport
-{
-       $_ = $_[0];
-
-       if (!/^\d+$/) {
-               return 0; }
-       if (/^0./) {
-               return 0; }
-       if ($_ >= 1 && $_ <= 65535) {
-               return 1; }
-       return 0;
-}
-
-sub validmac
-{
-       my $checkmac = $_[0];
-       my $ot = '[0-9a-f]{2}'; # 2 Hex digits (one octet)
-       if ($checkmac !~ /^$ot:$ot:$ot:$ot:$ot:$ot$/i)
-       {
-               return 0;
-       }
-       return 1;
-}
-
-sub validhostname
-{
-       # Checks a hostname against RFC1035
-        my $hostname = $_[0];
-
-       # Each part should be at least two characters in length
-       # but no more than 63 characters
-       if (length ($hostname) < 2 || length ($hostname) > 63) {
-               return 0;}
-       # Only valid characters are a-z, A-Z, 0-9 and -
-       if ($hostname !~ /^[a-zA-Z0-9-]*$/) {
-               return 0;}
-       # First character can only be a letter or a digit
-       if (substr ($hostname, 0, 1) !~ /^[a-zA-Z0-9]*$/) {
-               return 0;}
-       # Last character can only be a letter or a digit
-       if (substr ($hostname, -1, 1) !~ /^[a-zA-Z0-9]*$/) {
-               return 0;}
-       return 1;
-}
-
-sub validdomainname
-{
-       # Checks a domain name against RFC1035
-        my $domainname = $_[0];
-       my @parts = split (/\./, $domainname);  # Split hostname at the '.'
-
-       foreach $part (@parts) {
-               # Each part should be at least two characters in length
-               # but no more than 63 characters
-               if (length ($part) < 2 || length ($part) > 63) {
-                       return 0;}
-               # Only valid characters are a-z, A-Z, 0-9 and -
-               if ($part !~ /^[a-zA-Z0-9-]*$/) {
-                       return 0;}
-               # First character can only be a letter or a digit
-               if (substr ($part, 0, 1) !~ /^[a-zA-Z0-9]*$/) {
-                       return 0;}
-               # Last character can only be a letter or a digit
-               if (substr ($part, -1, 1) !~ /^[a-zA-Z0-9]*$/) {
-                       return 0;}
-       }
-       return 1;
-}
-
-sub validfqdn
-{
-       # Checks a fully qualified domain name against RFC1035
-        my $fqdn = $_[0];
-       my @parts = split (/\./, $fqdn);        # Split hostname at the '.'
-       if (scalar(@parts) < 2) {               # At least two parts should
-               return 0;}                      # exist in a FQDN
-                                               # (i.e. hostname.domain)
-       foreach $part (@parts) {
-               # Each part should be at least two characters in length
-               # but no more than 63 characters
-               if (length ($part) < 2 || length ($part) > 63) {
-                       return 0;}
-               # Only valid characters are a-z, A-Z, 0-9 and -
-               if ($part !~ /^[a-zA-Z0-9-]*$/) {
-                       return 0;}
-               # First character can only be a letter or a digit
-               if (substr ($part, 0, 1) !~ /^[a-zA-Z0-9]*$/) {
-                       return 0;}
-               # Last character can only be a letter or a digit
-               if (substr ($part, -1, 1) !~ /^[a-zA-Z0-9]*$/) {
-                       return 0;}
-       }
-       return 1;
-}
-
-sub validportrange # used to check a port range 
-{
-       my $port = $_[0]; # port values
-       $port =~ tr/-/:/; # replace all - with colons just in case someone used -
-       my $srcdst = $_[1]; # is it a source or destination port
-
-       if (!($port =~ /^(\d+)\:(\d+)$/)) {
-       
-               if (!(&validport($port))) {      
-                       if ($srcdst eq 'src'){
-                               return $tr{'source port numbers'};
-                       } else  {
-                               return $tr{'destination port numbers'};
-                       } 
-               }
-       }
-       else 
-       {
-               @ports = ($1, $2);
-               if ($1 >= $2){
-                       if ($srcdst eq 'src'){
-                               return $tr{'bad source range'};
-                       } else  {
-                               return $tr{'bad destination range'};
-                       } 
-               }
-               foreach $_ (@ports)
-               {
-                       if (!(&validport($_))) {
-                               if ($srcdst eq 'src'){
-                                       return $tr{'source port numbers'}; 
-                               } else  {
-                                       return $tr{'destination port numbers'};
-                               } 
-                       }
-               }
-               return;
-       }
-}
 
 # Test if IP is within a subnet
 # Call: IpInSubnet (Addr, Subnet, Subnet Mask)
@@ -1248,203 +294,58 @@ sub IpInSubnet
     return (($ip >= $start) && ($ip <= $end));
 }
 
-sub validemail {
-    my $mail = shift;
-    return 0 if ( $mail !~ /^[0-9a-zA-Z\.\-\_]+\@[0-9a-zA-Z\.\-]+$/ );
-    return 0 if ( $mail =~ /^[^0-9a-zA-Z]|[^0-9a-zA-Z]$/);
-    return 0 if ( $mail !~ /([0-9a-zA-Z]{1})\@./ );
-    return 0 if ( $mail !~ /.\@([0-9a-zA-Z]{1})/ );
-    return 0 if ( $mail =~ /.\.\-.|.\-\..|.\.\..|.\-\-./g );
-    return 0 if ( $mail =~ /.\.\_.|.\-\_.|.\_\..|.\_\-.|.\_\_./g );
-    return 0 if ( $mail !~ /\.([a-zA-Z]{2,3})$/ );
-    return 1;
+sub escape($) {
+       my $s = shift;
+       return HTML::Entities::encode_entities($s);
 }
 
-sub readhasharray {
-    my ($filename, $hash) = @_;
-
-    open(FILE, $filename) or die "Unable to read file $filename";
+sub cleanhtml {
+       my $outstring =$_[0];
+       $outstring =~ tr/,/ / if not defined $_[1] or $_[1] ne 'y';
 
-    while (<FILE>) {
-       my ($key, $rest, @temp);
-       chomp;
-       ($key, $rest) = split (/,/, $_, 2);
-       if ($key =~ /^[0-9]+$/ && $rest) {
-           @temp = split (/,/, $rest);
-           $hash->{$key} = \@temp;
-        }
-    }
-    close FILE;
-    return;
+       return escape($outstring);
 }
 
-sub writehasharray {
-    my ($filename, $hash) = @_;
-    my ($key, @temp);
+sub connectionstatus
+{
+    my %pppsettings = ();
+    my %netsettings = ();
+    my $iface='';
 
-    open(FILE, ">$filename") or die "Unable to write to file $filename";
+    $pppsettings{'PROFILENAME'} = 'None';
+    &General::readhash("${General::swroot}/ppp/settings", \%pppsettings);
+    &General::readhash("${General::swroot}/ethernet/settings", \%netsettings);
 
-    foreach $key (keys %$hash) {
-       if ( $hash->{$key} ) {
-           print FILE "$key";
-           foreach $i (0 .. $#{$hash->{$key}}) {
-               print FILE ",$hash->{$key}[$i]";
-           }
-       }
-       print FILE "\n";
+    my $profileused='';
+    unless ( $netsettings{'RED_TYPE'} =~ /^(DHCP|STATIC)$/ ) {
+       $profileused="- $pppsettings{'PROFILENAME'}";
     }
-    close FILE;
-    return;
-}
 
-sub findhasharraykey {
-    foreach my $i (1 .. 1000000) {
-       if ( ! exists $_[0]{$i}) {
-            return $i;
-       }
-    }
-}
+    my ($timestr, $connstate);
 
-sub cleanhtml
-{
-       my $outstring =$_[0];
-       $outstring =~ tr/,/ / if not defined $_[1] or $_[1] ne 'y';
-       $outstring =~ s/&/&amp;/g;
-       $outstring =~ s/\'/&#039;/g;
-       $outstring =~ s/\"/&quot;/g;
-       $outstring =~ s/</&lt;/g;
-       $outstring =~ s/>/&gt;/g;
-       return $outstring;
-}
-sub connectionstatus
-{
-        my $status;
-        opendir UPLINKS, "/var/ipfire/uplinks" or die "Cannot read uplinks: $!";
-                foreach my $uplink (sort grep !/^\./, readdir UPLINKS) {
-                    if ( -f "${swroot}/uplinks/${uplink}/active") {
-                        if ( ! $status ) {
-                                $timestr = &age("${swroot}/uplinks/${uplink}/active");
-                                $status = "$tr{'connected'}: $uplink (<span class='ipcop_StatusBigRed'>$timestr</span>) ";
-                        } else {
-                                $timestr = &age("${swroot}/uplinks/${uplink}/active");
-                                $status = "$status , $uplink (<span class='ipcop_StatusBigRed'>$timestr</span>) ";
-                        }
-                    } elsif ( -f "${swroot}/uplinks/${uplink}/connecting") {
-                        if ( ! $status ) {
-                                $status = "$tr{'connecting'} $uplink";
-                        } else {
-                                $status = "$status , $tr{'connecting'} $uplink (<span class='ipcop_StatusBigRed'>$timestr</span>) ";
-                        }
-                    }
-                    $lines++;
-                }
-                closedir(UPLINKS);
-                if ( ! $status ) {
-                        $status = "$tr{'idle'}";
-                }
-                $connstate = "<span class='ipcop_StatusBig'>$status</span>";
-    return $connstate;
-}
+               my $connstate = "<span>$Lang::tr{'idle'} $profileused</span>";
 
-sub srtarray 
-# Darren Critchley - darrenc@telus.net - (c) 2003
-# &srtarray(SortOrder, AlphaNumeric, SortDirection, ArrayToBeSorted)
-# This subroutine will take the following parameters:
-#   ColumnNumber = the column which you want to sort on, starts at 1
-#   AlphaNumberic = a or n (lowercase) defines whether the sort should be alpha or numberic
-#   SortDirection = asc or dsc (lowercase) Ascending or Descending sort
-#   ArrayToBeSorted = the array that wants sorting
-#
-#   Returns an array that is sorted to your specs
-#
-#   If SortOrder is greater than the elements in array, then it defaults to the first element
-# 
-{
-       my ($colno, $alpnum, $srtdir, @tobesorted) = @_;
-       my @tmparray;
-       my @srtedarray;
-       my $line;
-       my $newline;
-       my $ttlitems = scalar @tobesorted; # want to know the number of rows in the passed array
-       if ($ttlitems < 1){ # if no items, don't waste our time lets leave
-               return (@tobesorted);
-       }
-       my @tmp = split(/\,/,$tobesorted[0]);
-       $ttlitems = scalar @tmp; # this should be the number of elements in each row of the passed in array
-
-       # Darren Critchley - validate parameters
-       if ($colno > $ttlitems){$colno = '1';}
-       $colno--; # remove one from colno to deal with arrays starting at 0
-       if($colno < 0){$colno = '0';}
-       if ($alpnum ne '') { $alpnum = lc($alpnum); } else { $alpnum = 'a'; }
-       if ($srtdir ne '') { $srtdir = lc($srtdir); } else { $srtdir = 'src'; }
-
-       foreach $line (@tobesorted)
-       {
-               chomp($line);
-               if ($line ne '') {
-                       my @temp = split(/\,/,$line);
-                       # Darren Critchley - juggle the fields so that the one we want to sort on is first
-                       my $tmpholder = $temp[0];
-                       $temp[0] = $temp[$colno];
-                       $temp[$colno] = $tmpholder;
-                       $newline = "";
-                       for ($ctr=0; $ctr < $ttlitems ; $ctr++) {
-                               $newline=$newline . $temp[$ctr] . ",";
-                       }
-                       chop($newline);
-                       push(@tmparray,$newline);
-               }
-       }
-       if ($alpnum eq 'n') {
-               @tmparray = sort {$a <=> $b} @tmparray;
-       } else {
-               @tmparray = (sort @tmparray);
-       }
-       foreach $line (@tmparray)
-       {
-               chomp($line);
-               if ($line ne '') {
-                       my @temp = split(/\,/,$line);
-                       my $tmpholder = $temp[0];
-                       $temp[0] = $temp[$colno];
-                       $temp[$colno] = $tmpholder;
-                       $newline = "";
-                       for ($ctr=0; $ctr < $ttlitems ; $ctr++){
-                               $newline=$newline . $temp[$ctr] . ",";
+               if (-e "${General::swroot}/red/active") {
+                       $timestr = &General::age("${General::swroot}/red/active");
+                       $connstate = "<span>$Lang::tr{'connected'} - (<span>$timestr</span>) $profileused</span>";
+               } else {
+                 if ((open(KEEPCONNECTED, "</var/ipfire/red/keepconnected") == false) && ($pppsettings{'RECONNECTION'} eq "persistent")) {
+                               $connstate = "<span>$Lang::tr{'connection closed'} $profileused</span>";
+      } elsif (($pppsettings{'RECONNECTION'} eq "dialondemand") && ( -e "${General::swroot}/red/dial-on-demand")) {
+                               $connstate = "<span>$Lang::tr{'dod waiting'} $profileused</span>";
+                       } else {
+                               $connstate = "<span>$Lang::tr{'connecting'} $profileused</span>" if (system("ps -ef | grep -q '[p]ppd'"));
                        }
-                       chop($newline);
-                       push(@srtedarray,$newline);
-               }
-       }
-
-       if ($srtdir eq 'dsc') {
-               @tmparray = reverse(@srtedarray);
-               return (@tmparray);
-       } else {
-               return (@srtedarray);
-       }
-}
-
-sub speedtouchversion
-{
-       if (-f "/proc/bus/usb/devices")
-       {
-               $speedtouch=`/bin/cat /proc/bus/usb/devices | /bin/grep 'Vendor=06b9 ProdID=4061' | /usr/bin/cut -d ' ' -f6`;
-               if ($speedtouch eq '') {
-                       $speedtouch= $tr{'connect the modem'};
                }
-       } else {
-               $speedtouch='USB '.$tr{'not running'};
-       }
-       return $speedtouch
+               
+    return $connstate;
 }
 
 sub CheckSortOrder {
 #Sorting of allocated leases
     if ($ENV{'QUERY_STRING'} =~ /^IPADDR|^ETHER|^HOSTNAME|^ENDTIME/ ) {
-       my $newsort=$ENV{'QUERY_STRING'};
-        &readhash("${swroot}/dhcp/settings", \%dhcpsettings);
+        my $newsort=$ENV{'QUERY_STRING'};
+        &General::readhash("${swroot}/dhcp/settings", \%dhcpsettings);
         $act=$dhcpsettings{'SORT_LEASELIST'};
         #Reverse actual ?
         if ($act =~ $newsort) {
@@ -1453,7 +354,7 @@ sub CheckSortOrder {
         };
 
         $dhcpsettings{'SORT_LEASELIST'}=$newsort;
-       &writehash("${swroot}/dhcp/settings", \%dhcpsettings);
+        &General::writehash("${swroot}/dhcp/settings", \%dhcpsettings);
         $dhcpsettings{'ACTION'} = 'SORT';  # avoid the next test "First lauch"
     }
 
@@ -1468,12 +369,13 @@ sub PrintActualLeases
 <td width='25%' align='center'><a href='$ENV{'SCRIPT_NAME'}?IPADDR'><b>$tr{'ip address'}</b></a></td>
 <td width='25%' align='center'><a href='$ENV{'SCRIPT_NAME'}?ETHER'><b>$tr{'mac address'}</b></a></td>
 <td width='20%' align='center'><a href='$ENV{'SCRIPT_NAME'}?HOSTNAME'><b>$tr{'hostname'}</b></a></td>
-<td width='30%' align='center'><a href='$ENV{'SCRIPT_NAME'}?ENDTIME'><b>$tr{'lease expires'} (local time d/m/y)</b></a></td>
+<td width='25%' align='center'><a href='$ENV{'SCRIPT_NAME'}?ENDTIME'><b>$tr{'lease expires'} (local time d/m/y)</b></a></td>
+<td width='5%' align='center'><b>Add to fix leases<b></td>
 </tr>
 END
     ;
 
-    open(LEASES,"/var/lib/dhcp/dhcpd.leases") or die "Can't open dhcpd.leases";
+    open(LEASES,"/var/state/dhcp/dhcpd.leases") or die "Can't open dhcpd.leases";
     while ($line = <LEASES>) {
        next if( $line =~ /^\s*#/ );
        chomp($line);
@@ -1514,7 +416,7 @@ END
 
     my $id = 0;
     foreach my $key (sort leasesort keys %entries) {
-
+       print "<form method='post' action='/cgi-bin/dhcp.cgi'>\n";
        my $hostname = &cleanhtml($entries{$key}->{HOSTNAME},"y");
 
        if ($id % 2) {
@@ -1525,10 +427,10 @@ END
        }
 
        print <<END
-<td align='center'>$entries{$key}->{IPADDR}</td>
-<td align='center'>$entries{$key}->{ETHER}</td>
-<td align='center'>&nbsp;$hostname </td>
-<td align='center'>
+<td align='center'><input type='hidden' name='FIX_ADDR' value='$entries{$key}->{IPADDR}' />$entries{$key}->{IPADDR}</td>
+<td align='center'><input type='hidden' name='FIX_MAC' value='$entries{$key}->{ETHER}' />$entries{$key}->{ETHER}</td>
+<td align='center'><input type='hidden' name='FIX_REMARK' value='$hostname' />&nbsp;$hostname</td>
+<td align='center'><input type='hidden' name='FIX_ENABLED' value='on' />
 END
        ;
 
@@ -1540,7 +442,11 @@ END
        } else {
            print "$enddate";
        }
-       print "</td></tr>";
+       print <<END
+<td><input type='hidden' name='ACTION' value='$Lang::tr{'add'}2' /><input type='submit' name='SUBMIT' value='$Lang::tr{'add'}' />
+</td></td></tr></form>
+END
+       ;
        $id++;
     }
 
@@ -1581,70 +487,28 @@ sub leasesort {
     }
 }
 
-sub get_uplinks() {
-    my @uplinks = ();
-    opendir(DIR, "${swroot}/uplinks/") || return \@uplinks;
-    foreach my $dir (readdir(DIR)) {
-       next if ($dir =~ /^\./);
-       next if (-f "${swroot}/uplinks/$dir");
-       push(@uplinks, $dir);
-    }
-    closedir(DIR);
-    return \@uplinks;
-}
-
-sub get_iface($) {
-    my $filename = shift;
-    chomp($filename);
-    open (F, $filename) || return "";
-    my $iface = <F>;
-    close(F);
-    chomp($iface);
-    return $iface;
-}
-
-sub get_red_ifaces_by_type($) {
-    my $type=shift;
-    my @gottypeiface = ();
-    my @gottypeuplink = ();
-    my @gottype = ();
-
-    my $ref=get_uplinks();
-    my @uplinks=@$ref;
-    my %set = ();
-    foreach my $link (@uplinks) {
-       eval {
-           &readhash("${swroot}/uplinks/$link/settings", \%set);
-       };
-       push(@gottype, $link);
-
-       my $iface = $set{'RED_DEV'};
-       if (!$iface) {
-           $iface = get_iface("${swroot}/uplinks/$link/interface");
-       }
-       next if (!$iface);
-
-       if ($set{'RED_TYPE'} eq $type) {
-           push(@gottypeiface, $iface);
-           push(@gottypeuplink, $link);
+sub colorize {
+       my $string =  $_[0];
+       my @array = split(/\//,$string);
+       my $string2 = $array[0];
+
+       if ( $string eq "*" or $string eq "" ){
+               return $string;
+       } elsif ( $string =~ "ipsec" ){
+               return "<font color='".${Header::colourvpn}."'>".$string."</font>";
+       } elsif ( $string =~ "tun" ){
+               return "<font color='".${Header::colourovpn}."'>".$string."</font>";
+       } elsif ( $string =~ "lo" or $string =~ "127.0.0.0" ){
+               return "<font color='".${Header::colourfw}."'>".$string."</font>";
+       } elsif ( $string =~ $ethsettings{'GREEN_DEV'} or &IpInSubnet($string2,$ethsettings{'GREEN_NETADDRESS'},$ethsettings{'GREEN_NETMASK'}) ){
+               return "<font color='".${Header::colourgreen}."'>".$string."</font>";
+       } elsif (  $string =~ "ppp0" or $string =~ $ethsettings{'RED_DEV'} or $string =~ "0.0.0.0" or $string =~ $ethsettings{'RED_ADDRESS'} ){
+               return "<font color='".${Header::colourred}."'>".$string."</font>";
+       } elsif ( $ethsettings{'CONFIG_TYPE'}>1 and ( $string =~ $ethsettings{'BLUE_DEV'} or &IpInSubnet($string2,$ethsettings{'BLUE_NETADDRESS'},$ethsettings{'BLUE_NETMASK'}) )){
+               return "<font color='".${Header::colourblue}."'>".$string."</font>";
+       } elsif ( $ethsettings{'CONFIG_TYPE'}>2 and ( $string =~ $ethsettings{'ORANGE_DEV'} or &IpInSubnet($string2,$ethsettings{'ORANGE_NETADDRESS'},$ethsettings{'ORANGE_NETMASK'}) )){
+               return "<font color='".${Header::colourorange}."'>".$string."</font>";
+       } else {
+               return $string;
        }
-    }
-    return (\@gottypeiface, \@gottypeuplink, \@gottype);
-}
-
-sub get_red_ifaces() {
-    return `cat ${swroot}/uplinks/*/interface 2>/dev/null`;
-}
-
-sub get_zone_devices($) {
-    my $bridge = shift;
-    my @ifaces = ();
-    open (FILE, "${swroot}/ethernet/$bridge") || return "";
-    foreach my $line (<FILE>) {
-       chomp($line);
-       next if (!$line);
-       push(@ifaces, $line);
-    }
-    close(FILE);
-    return \@ifaces;
 }