]> git.ipfire.org Git - people/pmueller/ipfire-2.x.git/blobdiff - config/cfgroot/header.pl
ipfireseeder: update for 2.9 core44.
[people/pmueller/ipfire-2.x.git] / config / cfgroot / header.pl
index 0d775f0e183a31d35a00cc026b73a55205ba778a..bbb0eca79c88e25a70b7135ed878635d3cad8d81 100644 (file)
@@ -308,7 +308,7 @@ sub cleanhtml
        $outstring =~ tr/,/ / if not defined $_[1] or $_[1] ne 'y';
        $outstring =~ s/&/&/g;
        $outstring =~ s/\'/'/g;
-       $outstring =~ s/\"/"/g;
+       $outstring =~ s/\"/"/g; #" This is just a workaround for the syntax highlighter
        $outstring =~ s/</&lt;/g;
        $outstring =~ s/>/&gt;/g;
        return $outstring;
@@ -325,113 +325,27 @@ sub connectionstatus
     &General::readhash("${General::swroot}/ethernet/settings", \%netsettings);
 
     my $profileused='';
-    if ( ! ( $netsettings{'CONFIG_TYPE'} =~ /^(1|2|3|4)$/ && $netsettings{'RED_TYPE'} =~ /^(DHCP|STATIC)$/ ) ) {
+    unless ( $netsettings{'RED_TYPE'} =~ /^(DHCP|STATIC)$/ ) {
        $profileused="- $pppsettings{'PROFILENAME'}";
     }
 
-    if ( ( $pppsettings{'METHOD'} eq 'DHCP' && $netsettings{'RED_TYPE'} ne 'PPTP') 
-                                               || $netsettings{'RED_TYPE'} eq 'DHCP' ) {
-               if (open(IFACE, "${General::swroot}/red/iface")) {
-                       $iface = <IFACE>;
-                       close IFACE;
-                       chomp ($iface);
-                       $iface =~ /([a-zA-Z0-9]*)/; $iface = $1;
-               }
-    }
-
     my ($timestr, $connstate);
-    if ($netsettings{'CONFIG_TYPE'} =~ /^(0|1|2|3|4)$/ &&  $pppsettings{'TYPE'} =~ /^isdn/) {
-       # Count ISDN channels
-       my ($idmap, $chmap, $drmap, $usage, $flags, $phone);
-       my @phonenumbers;
-       my $count=0;
-
-       open (FILE, "/dev/isdninfo");
 
-       $idmap = <FILE>; chop $idmap;
-       $chmap = <FILE>; chop $chmap;
-       $drmap = <FILE>; chop $drmap;
-       $usage = <FILE>; chop $usage;
-       $flags = <FILE>; chop $flags;
-       $phone = <FILE>; chop $phone;
+               my $connstate = "<span>$Lang::tr{'idle'} $profileused</span>";
 
-       $phone =~ s/^phone(\s*):(\s*)//;
-
-       @phonenumbers = split / /, $phone;
-
-       foreach (@phonenumbers) {
-               if ($_ ne '???') {
-                       $count++;
-               }
-       }
-       close (FILE);
-
-       ## Connection status
-       my $number;
-       if ($count == 0) {
-               $number = 'none!';
-       } elsif ($count == 1) {
-               $number = 'single';
-       } else {
-               $number = 'dual';
-       }
-
-       if (-e "${General::swroot}/red/active") {
-               $timestr = &General::age("${General::swroot}/red/active");
-               $connstate = "<span class='ipcop_StatusBig'>$Lang::tr{'connected'} - $number channel (<span class='ipcop_StatusBigRed'>$timestr</span>) $profileused</span>";
-       } else {
-               if ($count == 0) {
-                       if (-e "${General::swroot}/red/dial-on-demand") {
-                               $connstate = "<span class='ipcop_StatusBig'>$Lang::tr{'dod waiting'} $profileused</span>";
-                       } else {
-                               $connstate = "<span class='ipcop_StatusBig'>$Lang::tr{'idle'} $profileused</span>";
-                       }
+               if (-e "${General::swroot}/red/active") {
+                       $timestr = &General::age("${General::swroot}/red/active");
+                       $connstate = "<span>$Lang::tr{'connected'} - (<span>$timestr</span>) $profileused</span>";
                } else {
-                       $connstate = "<span class='ipcop_StatusBig'>$Lang::tr{'connecting'} $profileused</span>";
-               }
-       }
-    } elsif ($netsettings{'RED_TYPE'} eq "STATIC" || $pppsettings {'METHOD'} eq 'STATIC') {
-       if (-e "${General::swroot}/red/active") {
-               $timestr = &General::age("${General::swroot}/red/active");
-               $connstate = "<span class='ipcop_StatusBig'>$Lang::tr{'connected'} (<span class='ipcop_StatusBigRed'>$timestr</span>) $profileused</span>";
-       } else {
-               $connstate = "<span class='ipcop_StatusBig'>$Lang::tr{'idle'} $profileused</span>";
-       }
-    } elsif ( ( (-e "${General::swroot}/dhcpc/dhcpcd-$iface.pid") && $netsettings{'RED_TYPE'} ne 'PPTP' ) || 
-       !system("/bin/ps -ef | /bin/grep -q '[p]ppd'") || !system("/bin/ps -ef | /bin/grep -q '[c]onnectioncheck'")) {
-       if (-e "${General::swroot}/red/active") {
-               $timestr = &General::age("${General::swroot}/red/active");
-               if ($pppsettings{'TYPE'} =~ /^(modem|bewanadsl|conexantpciadsl|eagleusbadsl)$/) {
-                       my $speed;
-                       if ($pppsettings{'TYPE'} eq 'modem') {
-                               open(CONNECTLOG, "/var/log/connect.log");
-                               while (<CONNECTLOG>) {
-                                       if (/CONNECT/) {
-                                               $speed = (split / /)[6];
-                                       }
-                               }
-                               close (CONNECTLOG);
-                       } elsif ($pppsettings{'TYPE'} eq 'bewanadsl') {
-                               $speed = `/usr/bin/unicorn_status | /bin/grep Rate | /usr/bin/cut -f2 -d ':'`;
-                       } elsif ($pppsettings{'TYPE'} eq 'conexantpciadsl') {
-                               $speed = `/bin/cat /proc/net/atm/CnxAdsl:* | /bin/grep 'Line Rates' | /bin/sed -e 's+Line Rates:   Receive+Rx+' -e 's+Transmit+Tx+'`;
-                       } elsif ($pppsettings{'TYPE'} eq 'eagleusbadsl') {
-                               $speed = `/usr/sbin/eaglestat | /bin/grep Rate`;
+                 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'"));
                        }
-                       $connstate = "$Lang::tr{'connected'} ($timestr) $profileused (\@$speed)";
-               } else {
-                       $connstate = "$Lang::tr{'connected'} ($timestr) $profileused";
-               }
-       } else {
-               if (-e "${General::swroot}/red/dial-on-demand") {
-                   $connstate = "$Lang::tr{'dod waiting'} $profileused";
-               } else {
-                   $connstate = "$Lang::tr{'connecting'} $profileused";
                }
-       }
-    } else {
-       $connstate = "$Lang::tr{'idle'} $profileused";
-    }
+               
     return $connstate;
 }
 
@@ -439,7 +353,7 @@ sub CheckSortOrder {
 #Sorting of allocated leases
     if ($ENV{'QUERY_STRING'} =~ /^IPADDR|^ETHER|^HOSTNAME|^ENDTIME/ ) {
         my $newsort=$ENV{'QUERY_STRING'};
-        &readhash("${swroot}/dhcp/settings", \%dhcpsettings);
+        &General::readhash("${swroot}/dhcp/settings", \%dhcpsettings);
         $act=$dhcpsettings{'SORT_LEASELIST'};
         #Reverse actual ?
         if ($act =~ $newsort) {
@@ -448,7 +362,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"
     }
 
@@ -580,3 +494,29 @@ sub leasesort {
        }
     }
 }
+
+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;
+       }
+}