Revision: 6005 http://ipcop.svn.sourceforge.net/ipcop/?rev=6005&view=rev Author: owes Date: 2011-10-29 13:20:38 +0000 (Sat, 29 Oct 2011) Log Message: ----------- Use connecting and disconnecting flag files, to display properly on index.cgi
Modified Paths: -------------- ipcop/trunk/src/libs/general-functions.pl Modified: ipcop/trunk/src/libs/general-functions.pl =================================================================== --- ipcop/trunk/src/libs/general-functions.pl 2011-10-29 13:19:34 UTC (rev 6004) +++ ipcop/trunk/src/libs/general-functions.pl 2011-10-29 13:20:38 UTC (rev 6005) @@ -719,6 +719,8 @@ my $connstate; my $timestr = &General::age('/var/ipcop/red/active'); my $dialondemand = (-e '/var/ipcop/red/dial-on-demand') ? 1 : 0; + my $connecting = (-e '/var/ipcop/red/connecting') ? 1 : 0; + my $disconnecting = (-e '/var/ipcop/red/disconnecting') ? 1 : 0; if (($netsettings{'RED_COUNT'} == 0) && ($pppsettings{'TYPE'} =~ /^isdn/)) { @@ -770,7 +772,13 @@ "<span class='ipcop_StatusBig'>$Lang::tr{'connected'} - $number channel (<span class='ipcop_StatusBigRed'>$timestr</span>) $profileused</span>"; } else { - if ($count == 0) { + if ($connecting) { + $connstate = "<span class='ipcop_StatusBig'>$Lang::tr{'connecting'} $profileused</span>"; + } + elsif ($disconnecting) { + $connstate = "<span class='ipcop_StatusBig'>$Lang::tr{'disconnecting'} $profileused</span>"; + } + elsif ($count == 0) { if ($dialondemand) { $connstate = "<span class='ipcop_StatusBig'>$Lang::tr{'dod waiting'} $profileused</span>"; } @@ -779,6 +787,7 @@ } } else { + # Final resort, should not happen $connstate = "<span class='ipcop_StatusBig'>$Lang::tr{'connecting'} $profileused</span>"; } } @@ -792,54 +801,50 @@ $connstate = "<span class='ipcop_StatusBig'>$Lang::tr{'idle'} $profileused</span>"; } } - elsif (((-e "/var/run/dhcpcd-$iface.pid") && ($netsettings{'RED_1_TYPE'} ne 'PPTP')) - || !system("/bin/ps -ef | /bin/grep -q '[p]ppd'") - || !system("/bin/ps -ef | /bin/grep -q '[c]onnectioncheck'")) - { - if ($timestr) { - if ($netsettings{'RED_1_TYPE'} eq 'DHCP') { - $connstate = + elsif ($timestr) { + if ($netsettings{'RED_1_TYPE'} eq 'DHCP') { + $connstate = "<span class='ipcop_StatusBig'>$Lang::tr{'connected'} (<span class='ipcop_StatusBigRed'>$timestr</span>) $profileused</span>"; - } - elsif ($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]; - } + } + elsif ($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 ':'`; - $speed =~ s/(\d+) (\d+)/\1kbits \2kbits/; - } - elsif ($pppsettings{'TYPE'} eq 'conexantpciadsl') { - $speed = + close(CONNECTLOG); + } + elsif ($pppsettings{'TYPE'} eq 'bewanadsl') { + $speed = `/usr/bin/unicorn_status | /bin/grep Rate | /usr/bin/cut -f2 -d ':'`; + $speed =~ s/(\d+) (\d+)/\1kbits \2kbits/; + } + 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`; - } - $connstate = -"<span class='ipcop_StatusBig'>$Lang::tr{'connected'} (<span class='ipcop_StatusBigRed'>$timestr</span>) $profileused (\@$speed)</span>"; } - else { - $connstate = -"<span class='ipcop_StatusBig'>$Lang::tr{'connected'} (<span class='ipcop_StatusBigRed'>$timestr</span>) $profileused</span>"; + elsif ($pppsettings{'TYPE'} eq 'eagleusbadsl') { + $speed = `/usr/sbin/eaglestat | /bin/grep Rate`; } + $connstate = +"<span class='ipcop_StatusBig'>$Lang::tr{'connected'} (<span class='ipcop_StatusBigRed'>$timestr</span>) $profileused (\@$speed)</span>"; } else { - if ($dialondemand) { - $connstate = "<span class='ipcop_StatusBig'>$Lang::tr{'dod waiting'} $profileused</span>"; - } - else { - $connstate = "<span class='ipcop_StatusBig'>$Lang::tr{'connecting'} $profileused</span>"; - } + $connstate = +"<span class='ipcop_StatusBig'>$Lang::tr{'connected'} (<span class='ipcop_StatusBigRed'>$timestr</span>) $profileused</span>"; } } + elsif ($dialondemand) { + $connstate = "<span class='ipcop_StatusBig'>$Lang::tr{'dod waiting'} $profileused</span>"; + } + elsif ($connecting) { + $connstate = "<span class='ipcop_StatusBig'>$Lang::tr{'connecting'} $profileused</span>"; + } + elsif ($disconnecting) { + $connstate = "<span class='ipcop_StatusBig'>$Lang::tr{'disconnecting'} $profileused</span>"; + } else { $connstate = "<span class='ipcop_StatusBig'>$Lang::tr{'idle'} $profileused</span>"; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. ------------------------------------------------------------------------------ Get your Android app more play: Bring it to the BlackBerry PlayBook in minutes. BlackBerry App World™ now supports Android™ Apps for the BlackBerry® PlayBook™. Discover just how easy and simple it is! http://p.sf.net/sfu/android-dev2dev _______________________________________________ Ipcop-svn mailing list Ipcop-svn@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/ipcop-svn