]>
git.ipfire.org Git - people/pmueller/ipfire-2.x.git/blob - config/cfgroot/header.pl
c15187a135ef46056e2b4b51f97bce08b132edcf
3 # This code is distributed under the terms of the GPL
5 # (c) The SmoothWall Team
6 # Copyright (C) 2002 Alex Hudson - getcgihash() rewrite
7 # Copyright (C) 2002 Bob Grant <bob@cache.ucr.edu> - validmac()
8 # Copyright (c) 2002/04/13 Steve Bootes - add alias section, helper functions
9 # Copyright (c) 2002/08/23 Mark Wormgoor <mark@wormgoor.com> validfqdn()
10 # Copyright (c) 2003/09/11 Darren Critchley <darrenc@telus.net> srtarray()
12 # $Id: header.pl,v 1.34.2.67 2005/10/03 20:01:05 gespinasse Exp $
21 # enable only the following on debugging purpose
23 #use CGI::Carp 'fatalsToBrowser';
26 $Header::pagecolour
= '#ffffff'; # never used, will be removed
27 $Header::tablecolour
= '#FFFFFF'; # never used, will be removed
28 $Header::bigboxcolour
= '#F6F4F4'; # never used, will be removed
29 $Header::boxcolour
= '#EAE9EE'; # only header.pl, ? move in css ?
30 $Header::bordercolour
= '#000000'; # never used, will be removed
31 $Header::table1colour
= '#C0C0C0';
32 $Header::table2colour
= '#F2F2F2';
33 $Header::colourred
= '#993333';
34 $Header::colourorange
= '#FF9933';
35 $Header::colouryellow
= '#FFFF00';
36 $Header::colourgreen
= '#339933';
37 $Header::colourblue
= '#333399';
38 $Header::colourfw
= '#000000'; # only connections.cgi
39 $Header::colourvpn
= '#990099'; # only connections.cgi
40 $Header::colourerr
= '#FF0000'; # only header.pl, many scripts use colourred for warnings messages
41 $Header::viewsize
= 150;
43 my $hostnameintitle = 0;
49 ### Initialize environment
51 &General
::readhash
("${General::swroot}/ethernet/settings", \
%ethsettings);
53 %{$menu{'1.system'}}=(
54 'contents' => $Lang::tr
{'alt system'},
56 'statusText' => "IPCop $Lang::tr{'alt system'}",
57 'subMenu' => [[ $Lang::tr
{'alt home'} , '/cgi-bin/index.cgi', "IPCop $Lang::tr{'alt home'}" ],
58 [ $Lang::tr
{'updates'} , '/cgi-bin/updates.cgi', "IPCop $Lang::tr{'updates'}" ],
59 [ $Lang::tr
{'sspasswords'} , '/cgi-bin/changepw.cgi', "IPCop $Lang::tr{'sspasswords'}" ],
60 [ $Lang::tr
{'ssh access'} , '/cgi-bin/remote.cgi', "IPCop $Lang::tr{'ssh access'}" ],
61 [ $Lang::tr
{'gui settings'} , '/cgi-bin/gui.cgi', "IPCop $Lang::tr{'gui settings'}" ],
62 [ $Lang::tr
{'backup'} , '/cgi-bin/backup.cgi', "IPCop $Lang::tr{'backup'} / $Lang::tr{'restore'}" ],
63 [ $Lang::tr
{'shutdown'} , '/cgi-bin/shutdown.cgi', "IPCop $Lang::tr{'shutdown'} / $Lang::tr{'reboot'}" ],
64 [ $Lang::tr
{'credits'} , '/cgi-bin/credits.cgi', "IPCop $Lang::tr{'credits'}" ]]
66 %{$menu{'2.status'}}=(
67 'contents' => $Lang::tr
{'status'},
69 'statusText' => "IPCop $Lang::tr{'status information'}",
70 'subMenu' => [[ $Lang::tr
{'sssystem status'} , '/cgi-bin/status.cgi', "IPCop $Lang::tr{'system status information'}" ],
71 [ $Lang::tr
{'ssnetwork status'} , '/cgi-bin/netstatus.cgi', "IPCop $Lang::tr{'network status information'}" ],
72 [ $Lang::tr
{'system graphs'} , '/cgi-bin/graphs.cgi', "IPCop $Lang::tr{'system graphs'}" ],
73 [ $Lang::tr
{'sstraffic graphs'} , '/cgi-bin/graphs.cgi?graph=network', "IPCop $Lang::tr{'network traffic graphs'}" ],
74 [ $Lang::tr
{'ssproxy graphs'} , '/cgi-bin/proxygraphs.cgi', "IPCop $Lang::tr{'proxy access graphs'}" ],
75 [ $Lang::tr
{'connections'} , '/cgi-bin/connections.cgi', "IPCop $Lang::tr{'connections'}" ]]
77 %{$menu{'3.network'}}=(
78 'contents' => $Lang::tr
{'network'},
80 'statusText' => "IPCop $Lang::tr{'network configuration'}",
81 'subMenu' => [[ $Lang::tr
{'alt dialup'} , '/cgi-bin/pppsetup.cgi', "IPCop $Lang::tr{'dialup settings'}" ],
82 [ $Lang::tr
{'upload'} , '/cgi-bin/upload.cgi', $Lang::tr
{'firmware upload'} ],
83 [ $Lang::tr
{'modem'} , '/cgi-bin/modem.cgi', "IPCop $Lang::tr{'modem configuration'}" ],
84 [ $Lang::tr
{'aliases'} , '/cgi-bin/aliases.cgi', "IPCop $Lang::tr{'external aliases configuration'}" ]]
86 %{$menu{'4.services'}}=(
87 'contents' => $Lang::tr
{'alt services'},
89 'statusText' => "IPCop $Lang::tr{'alt services'}",
90 'subMenu' => [[ $Lang::tr
{'proxy'} , '/cgi-bin/proxy.cgi', "IPCop $Lang::tr{'web proxy configuration'}" ],
91 [ $Lang::tr
{'dhcp server'} , '/cgi-bin/dhcp.cgi', "IPCop $Lang::tr{'dhcp configuration'}" ],
92 [ $Lang::tr
{'dynamic dns'} , '/cgi-bin/ddns.cgi', "IPCop $Lang::tr{'dynamic dns client'}" ],
93 [ $Lang::tr
{'edit hosts'} , '/cgi-bin/hosts.cgi', "IPCop $Lang::tr{'host configuration'}" ],
94 [ $Lang::tr
{'time server'} , '/cgi-bin/time.cgi', "IPCop $Lang::tr{'time server'}" ],
95 [ $Lang::tr
{'traffic shaping'} , '/cgi-bin/shaping.cgi', "IPCop $Lang::tr{'traffic shaping settings'}" ],
96 [ $Lang::tr
{'intrusion detection'} , '/cgi-bin/ids.cgi', "IPCop $Lang::tr{'intrusion detection system'} (Snort)" ]]
98 %{$menu{'5.firewall'}}=(
99 'contents' => $Lang::tr
{'firewall'},
101 'statusText' => "IPCop $Lang::tr{'firewall'}",
102 'subMenu' => [[ $Lang::tr
{'ssport forwarding'} , '/cgi-bin/portfw.cgi', "IPCop $Lang::tr{'port forwarding configuration'}" ],
103 [ $Lang::tr
{'external access'} , '/cgi-bin/xtaccess.cgi', "IPCop $Lang::tr{'external access configuration'}" ],
104 [ $Lang::tr
{'ssdmz pinholes'} , '/cgi-bin/dmzholes.cgi', "IPCop $Lang::tr{'dmz pinhole configuration'}" ],
105 [ $Lang::tr
{'blue access'} , '/cgi-bin/wireless.cgi', "IPCop $Lang::tr{'blue access'}" ]
106 ,[ $Lang::tr
{'options fw'} , '/cgi-bin/optionsfw.cgi', "IPCop $Lang::tr{'options fw'}" ]
110 'contents' => $Lang::tr
{'alt vpn'},
112 'statusText' => "IPCop $Lang::tr{'virtual private networking'}",
113 'subMenu' => [[ $Lang::tr
{'alt vpn'} , '/cgi-bin/vpnmain.cgi', "IPCop $Lang::tr{'virtual private networking'}"]]
115 %{$menu{'7.mainlogs'}}=(
116 'contents' => $Lang::tr
{'alt logs'},
118 'statusText' => "IPCop $Lang::tr{'alt logs'}",
119 'subMenu' => [[ $Lang::tr
{'log settings'} , '/cgi-bin/logs.cgi/config.dat', "IPCop $Lang::tr{'log settings'}" ],
120 [ $Lang::tr
{'log summary'} , '/cgi-bin/logs.cgi/summary.dat', "IPCop $Lang::tr{'log summary'}" ],
121 [ $Lang::tr
{'proxy logs'} , '/cgi-bin/logs.cgi/proxylog.dat', "IPCop $Lang::tr{'proxy log viewer'}" ],
122 [ $Lang::tr
{'firewall logs'} , '/cgi-bin/logs.cgi/firewalllog.dat', "IPCop $Lang::tr{'firewall log viewer'}" ],
123 [ $Lang::tr
{'ids logs'} , '/cgi-bin/logs.cgi/ids.dat', "IPCop $Lang::tr{'intrusion detection system log viewer'}" ],
124 [ $Lang::tr
{'system logs'} , '/cgi-bin/logs.cgi/log.dat', "IPCop $Lang::tr{'system log viewer'}" ]]
126 if (! $ethsettings{'BLUE_DEV'}) {
127 splice (@
{$menu{'5.firewall'}{'subMenu'}}, 3, 1);
129 if (! $ethsettings{'BLUE_DEV'} && ! $ethsettings{'ORANGE_DEV'}) {
130 splice (@
{$menu{'5.firewall'}{'subMenu'}}, 2, 1);
132 unless ( $ethsettings{'CONFIG_TYPE'} =~ /^(2|3|6|7)$/ && $ethsettings{'RED_TYPE'} eq 'STATIC' ) {
133 splice (@
{$menu{'3.network'}{'subMenu'}}, 3, 1);
135 if ( ! -e
"${General::swroot}/snort/enable" && ! -e
"${General::swroot}/snort/enable_blue" &&
136 ! -e
"${General::swroot}/snort/enable_green" && ! -e
"${General::swroot}/snort/enable_orange") {
137 splice (@
{$menu{'7.mainlogs'}{'subMenu'}}, 4, 1);
139 if ( ! -e
"${General::swroot}/proxy/enable" && ! -e
"${General::swroot}/proxy/enable_blue" ) {
140 splice (@
{$menu{'2.status'}{'subMenu'}}, 4, 1);
141 splice (@
{$menu{'7.mainlogs'}{'subMenu'}}, 2, 1);
147 ### Make sure this is an SSL request
148 if ($ENV{'SERVER_ADDR'} && $ENV{'HTTPS'} ne 'on') {
149 print "Status: 302 Moved\r\n";
150 print "Location: https://$ENV{'SERVER_ADDR'}:445/$ENV{'PATH_INFO'}\r\n\r\n";
153 print "Pragma: no-cache\n";
154 print "Cache-control: no-cache\n";
155 print "Connection: close\n";
156 print "Content-type: text/html\n\n";
164 print " <script type='text/javascript'>\n";
165 print " domMenu_data.setItem('domMenu_main', new domMenu_Hash(\n";
167 foreach my $k1 ( sort keys %menu ) {
172 print " $c1, new domMenu_Hash(\n";
173 print "\t'contents', '" . &cleanhtml
($menu{$k1}{'contents'}) . "',\n";
174 print "\t'uri', '$menu{$k1}{'uri'}',\n";
175 $menu{$k1}{'statusText'} =~ s/'/\\\'/g;
176 print "\t'statusText', '$menu{$k1}{'statusText'}',\n";
177 foreach my $k2 ( @
{$menu{$k1}{'subMenu'}} ) {
178 print "\t $c2, new domMenu_Hash(\n";
179 print "\t\t'contents', '" . &cleanhtml
(@
{$k2}[0]) . "',\n";
180 print "\t\t'uri', '@{$k2}[1]',\n";
181 @
{$k2}[2] =~ s/'/\\\'/g;
182 print "\t\t'statusText', '@{$k2}[2]'\n";
183 if ( $c2 <= $#{$menu{$k1}{'subMenu'}} ) {
196 domMenu_settings.setItem('domMenu_main', new domMenu_Hash(
197 'menuBarWidth', '0%',
198 'menuBarClass', 'ipcop_menuBar',
199 'menuElementClass', 'ipcop_menuElement',
200 'menuElementHoverClass', 'ipcop_menuElementHover',
201 'menuElementActiveClass', 'ipcop_menuElementHover',
202 'subMenuBarClass', 'ipcop_subMenuBar',
203 'subMenuElementClass', 'ipcop_subMenuElement',
204 'subMenuElementHoverClass', 'ipcop_subMenuElementHover',
205 'subMenuElementActiveClass', 'ipcop_subMenuElementHover',
206 'subMenuMinWidth', 'auto',
207 'distributeSpace', false,
208 'openMouseoverMenuDelay', 0,
209 'openMousedownMenuDelay', 0,
210 'closeClickMenuDelay', 0,
211 'closeMouseoutMenuDelay', -1
220 if ($javascript) {print "<noscript>";}
221 print "<table cellpadding='0' cellspacing='0' border='0'>\n";
224 foreach my $k1 ( sort keys %menu ) {
225 print "<td class='ipcop_menuElementTD'><a href='" . @
{@
{$menu{$k1}{'subMenu'}}[0]}[1] . "' class='ipcop_menuElementNoJS'>";
226 print $menu{$k1}{'contents'} . "</a></td>\n";
228 print "</tr></table>\n";
229 if ($javascript) {print "</noscript>";}
234 my $location = $_[0];
237 if ($javascript) {print "<noscript>";}
238 print "<table width='100%' cellspacing='0' cellpadding='5' border='0'>\n";
239 print "<tr><td style='background-color: $Header::boxcolour;' width='53'><img src='/images/null.gif' width='43' height='1' alt='' /></td>\n";
240 print "<td style='background-color: $Header::boxcolour;' align='left' width='100%'>";
241 my @URI=split ('\?', $ENV{'REQUEST_URI'} );
243 foreach my $k1 ( keys %menu ) {
245 if ($menu{$k1}{'contents'} eq $location) {
246 foreach my $k2 ( @
{$menu{$k1}{'subMenu'}} ) {
250 if (@
{$k2}[1] eq "$URI[0]\?$URI[1]" || (@
{$k2}[1] eq $URI[0] && length($URI[1]) == 0)) {
251 #if (@{$k2}[1] eq "$URI[0]") {
252 print "<b>@{$k2}[0]</b>";
254 print "<a href='@{$k2}[1]'>@{$k2}[0]</a>";
260 print "</td></tr></table>\n";
261 if ($javascript) { print "</noscript>";}
268 my $extrahead = $_[2];
270 ### Initialize environment
272 &General
::readhash
("${General::swroot}/main/settings", \
%settings);
274 if ($settings{'JAVASCRIPT'} eq 'off') {
280 if ($settings{'WINDOWWITHHOSTNAME'} eq 'on') {
281 $hostnameintitle = 1;
283 $hostnameintitle = 0;
288 PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
289 "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
295 if ($hostnameintitle) {
296 print "$settings{'HOSTNAME'}.$settings{'DOMAINNAME'} - $title";
298 print "IPCop - $title";
304 <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
305 <link rel="shortcut icon" href="/favicon.ico" />
306 <style type="text/css">\@import url(/include/ipcop.css);</style>
310 print "<script type='text/javascript' src='/include/domMenu.js'></script>\n";
318 my $sublocation = '';
319 my @URI=split ('\?', $ENV{'REQUEST_URI'} );
320 foreach my $k1 ( keys %menu ) {
321 my $temp = $menu{$k1}{'contents'};
322 foreach my $k2 ( @
{$menu{$k1}{'subMenu'}} ) {
323 if ( @
{$k2}[1] eq $URI[0] ) {
325 $sublocation = @
{$k2}[0];
330 my @cgigraphs = split(/graph=/,$ENV{'QUERY_STRING'});
331 if (defined ($cgigraphs[1])){
332 if ($cgigraphs[1] =~ /(GREEN|BLUE|ORANGE|RED|network)/) {
333 $location = $Lang::tr
{'status'};
334 $sublocation = $Lang::tr
{'sstraffic graphs'};
336 if ($cgigraphs[1] =~ /(cpu|memory|swap|disk)/) {
337 $location = $Lang::tr
{'status'};
338 $sublocation = $Lang::tr
{'system graphs'};
341 if ($ENV{'QUERY_STRING'} =~ /(ip)/) {
342 $location = $Lang::tr
{'alt logs'};
343 $sublocation = "WHOIS";
348 <script type="text/javascript">
349 document.onmouseup = function()
351 domMenu_deactivate('domMenu_main');
356 <body onload="domMenu_activate('domMenu_main');">
360 print "</head>\n\n<body>\n";
364 <!-- IPCOP HEADER -->
365 <table width='100%' cellpadding='0' cellspacing='0'>
368 <tr><td><img src='/images/null.gif' width='53' height='27' alt='' /></td>
369 <td valign='bottom'><table width='100%' cellspacing='0' border='0'>
373 <tr><td><img src='/images/null.gif' width='5' height='1' alt='' /></td>
374 <td class="ipcop_menuLocationMain" valign='bottom'>$location</td>
375 <td class="ipcop_menuLocationSub" valign='bottom'>$sublocation</td>
378 <tr><td valign='bottom' class='ipcop_Version'>
379 <img src='/images/null.gif' width='1' height='29' alt='' />${General::version}</td>
385 print "<div id='domMenu_main'></div>\n";
389 print " </td></tr></table>\n";
390 &showsubsection
($location);
391 print "<!-- IPCOP CONTENT -->\n";
397 <!-- IPCOP FOOTER -->
398 <table width='100%' border='0'>
399 <tr><td valign='bottom'><img src='/images/bounceback.png' width='248' height='80' alt='' /></td>
400 <td align='center' valign='bottom'>
403 my $status = &connectionstatus
();
404 print "$status<br />\n";
405 print `/usr/bin/uptime`;
409 <td valign='bottom'><a href='http://sf.net/projects/ipcop/' target='_blank'><img src='/images/sflogo.png' width='88' height='31' alt='Sourceforge logo' /></a></td>
421 my $errormessage = $_[3];
425 $bgcolor = "style='background-color: $Header::colourerr;'";
430 print "<table width='100%' border='0'>\n";
432 print "<tr><td valign='top'><img src='/images/$sideimg' width='65' height='345' alt='' /></td>\n";
436 print "<td valign='top' align='center'><table width='$width' $bgcolor cellspacing='0' cellpadding='10' border='0'>\n";
437 print "<tr><td><img src='/images/null.gif' width='1' height='365' alt='' /></td>\n";
438 print "<td align='$align' valign='top'>\n";
443 print "</td></tr></table></td></tr></table>\n"
453 <table cellspacing="0" cellpadding="0" width="$width" border="0">
460 <tr><td width='12' ><img src='/images/null.gif' width='12' height='1' alt='' /></td>
461 <td width='18' ><img src='/images/null.gif' width='18' height='1' alt='' /></td>
462 <td width='100%'><img src='/images/null.gif' width='400' height='1' alt='' /></td>
463 <td width='152' ><img src='/images/null.gif' width='152' height='1' alt='' /></td>
464 <td width='11' ><img src='/images/null.gif' width='11' height='1' alt='' /></td></tr>
465 <tr><td colspan='2' ><img src='/images/boxtop1.png' width='30' height='53' alt='' /></td>
466 <td style='background: url(/images/boxtop2.png);'>
469 if ($caption) { print "<b>$caption</b>\n"; } else { print " "; }
472 <td colspan='2'><img src='/images/boxtop3.png' width='163' height='53' alt='' /></td></tr>
473 <tr><td style='background: url(/images/boxleft.png);'><img src='/images/null.gif' width='12' height='1' alt='' /></td>
474 <td colspan='3' style='background-color: $Header::boxcolour;'>
475 <table width='100%' cellpadding='5'><tr><td align="$align" valign='top'>
483 </td></tr></table></td>
484 <td style='background: url(/images/boxright.png);'><img src='/images/null.gif' width='11' height='1' alt='' /></td></tr>
485 <tr><td style='background: url(/images/boxbottom1.png);background-repeat:no-repeat;'><img src='/images/null.gif' width='12' height='14' alt='' /></td>
486 <td style='background: url(/images/boxbottom2.png);background-repeat:repeat-x;' colspan='3'><img src='/images/null.gif' width='1' height='14' alt='' /></td>
487 <td style='background: url(/images/boxbottom3.png);background-repeat:no-repeat;'><img src='/images/null.gif' width='11' height='14' alt='' /></td></tr>
494 my ($hash, $params) = @_;
495 my $cgi = CGI
->new ();
496 return if ($ENV{'REQUEST_METHOD'} ne 'POST');
497 if (!$params->{'wantfile'}) {
498 $CGI::DISABLE_UPLOADS
= 1;
499 $CGI::POST_MAX
= 512 * 1024;
501 $CGI::POST_MAX
= 10 * 1024 * 1024;
504 $cgi->referer() =~ m/^https?\:\/\
/([^\/]+)/;
506 $cgi->url() =~ m/^https?\:\/\
/([^\/]+)/;
508 return if ($referer ne $servername);
510 ### Modified for getting multi-vars, split by |
511 my %temp = $cgi->Vars();
512 foreach my $key (keys %temp) {
513 $hash->{$key} = $temp{$key};
514 $hash->{$key} =~ s/\0/|/g;
515 $hash->{$key} =~ s/^\s*(.*?)\s*$/$1/;
518 if (($params->{'wantfile'})&&($params->{'filevar'})) {
519 $hash->{$params->{'filevar'}} = $cgi->upload
520 ($params->{'filevar'});
527 my $outstring =$_[0];
528 $outstring =~ tr/,/ / if not defined $_[1] or $_[1] ne 'y';
529 $outstring =~ s/&/&/g;
530 $outstring =~ s/\'/'/g;
531 $outstring =~ s/\"/"/g;
532 $outstring =~ s/</</g;
533 $outstring =~ s/>/>/g;
539 my %pppsettings = ();
540 my %netsettings = ();
543 $pppsettings{'PROFILENAME'} = 'None';
544 &General
::readhash
("${General::swroot}/ppp/settings", \
%pppsettings);
545 &General
::readhash
("${General::swroot}/ethernet/settings", \
%netsettings);
548 if ( ! ( $netsettings{'CONFIG_TYPE'} =~ /^(2|3|6|7)$/ && $netsettings{'RED_TYPE'} =~ /^(DHCP|STATIC)$/ ) ) {
549 $profileused="- $pppsettings{'PROFILENAME'}";
552 if ( ( $pppsettings{'METHOD'} eq 'DHCP' && $netsettings{'RED_TYPE'} ne 'PPTP')
553 || $netsettings{'RED_TYPE'} eq 'DHCP' ) {
554 if (open(IFACE
, "${General::swroot}/red/iface")) {
558 $iface =~ /([a-zA-Z0-9]*)/; $iface = $1;
562 my ($timestr, $connstate);
563 if ($netsettings{'CONFIG_TYPE'} =~ /^(0|1|4|5)$/ && $pppsettings{'TYPE'} =~ /^isdn/) {
564 # Count ISDN channels
565 my ($idmap, $chmap, $drmap, $usage, $flags, $phone);
569 open (FILE
, "/dev/isdninfo");
571 $idmap = <FILE
>; chop $idmap;
572 $chmap = <FILE
>; chop $chmap;
573 $drmap = <FILE
>; chop $drmap;
574 $usage = <FILE
>; chop $usage;
575 $flags = <FILE
>; chop $flags;
576 $phone = <FILE
>; chop $phone;
578 $phone =~ s/^phone(\s*):(\s*)//;
580 @phonenumbers = split / /, $phone;
582 foreach (@phonenumbers) {
593 } elsif ($count == 1) {
599 if (-e
"${General::swroot}/red/active") {
600 $timestr = &General
::age
("${General::swroot}/red/active");
601 $connstate = "<span class='ipcop_StatusBig'>$Lang::tr{'connected'} - $number channel (<span class='ipcop_StatusBigRed'>$timestr</span>) $profileused</span>";
604 if (-e
"${General::swroot}/red/dial-on-demand") {
605 $connstate = "<span class='ipcop_StatusBig'>$Lang::tr{'dod waiting'} $profileused</span>";
607 $connstate = "<span class='ipcop_StatusBig'>$Lang::tr{'idle'} $profileused</span>";
610 $connstate = "<span class='ipcop_StatusBig'>$Lang::tr{'connecting'} $profileused</span>";
613 } elsif ($netsettings{'RED_TYPE'} eq "STATIC" || $pppsettings {'METHOD'} eq 'STATIC') {
614 if (-e
"${General::swroot}/red/active") {
615 $timestr = &General
::age
("${General::swroot}/red/active");
616 $connstate = "<span class='ipcop_StatusBig'>$Lang::tr{'connected'} (<span class='ipcop_StatusBigRed'>$timestr</span>) $profileused</span>";
618 $connstate = "<span class='ipcop_StatusBig'>$Lang::tr{'idle'} $profileused</span>";
620 } elsif ( ( (-e
"${General::swroot}/dhcpc/dhcpcd-$iface.pid") && $netsettings{'RED_TYPE'} ne 'PPTP' ) ||
621 !system("/bin/ps -ef | /bin/grep -q '[p]ppd'") || !system("/bin/ps -ef | /bin/grep -q '[c]onnectioncheck'")) {
622 if (-e
"${General::swroot}/red/active") {
623 $timestr = &General
::age
("${General::swroot}/red/active");
624 if ($pppsettings{'TYPE'} =~ /^(modem|bewanadsl|conexantpciadsl|eagleusbadsl)$/) {
626 if ($pppsettings{'TYPE'} eq 'modem') {
627 open(CONNECTLOG
, "/var/log/connect.log");
628 while (<CONNECTLOG
>) {
630 $speed = (split / /)[6];
634 } elsif ($pppsettings{'TYPE'} eq 'bewanadsl') {
635 $speed = `/usr/bin/unicorn_status | /bin/grep Rate | /usr/bin/cut -f2 -d ':'`;
636 } elsif ($pppsettings{'TYPE'} eq 'conexantpciadsl') {
637 $speed = `/bin/cat /proc/net/atm/CnxAdsl:* | /bin/grep 'Line Rates' | /bin/sed -e 's+Line Rates: Receive+Rx+' -e 's+Transmit+Tx+'`;
638 } elsif ($pppsettings{'TYPE'} eq 'eagleusbadsl') {
639 $speed = `/usr/sbin/eaglestat | /bin/grep Rate`;
641 $connstate = "<span class='ipcop_StatusBig'>$Lang::tr{'connected'} (<span class='ipcop_StatusBigRed'>$timestr</span>) $profileused (\@$speed)</span>";
643 $connstate = "<span class='ipcop_StatusBig'>$Lang::tr{'connected'} (<span class='ipcop_StatusBigRed'>$timestr</span>) $profileused</span>";
646 if (-e
"${General::swroot}/red/dial-on-demand") {
647 $connstate = "<span class='ipcop_StatusBig'>$Lang::tr{'dod waiting'} $profileused</span>";
649 $connstate = "<span class='ipcop_StatusBig'>$Lang::tr{'connecting'} $profileused</span>";
653 $connstate = "<span class='ipcop_StatusBig'>$Lang::tr{'idle'} $profileused</span>";
658 sub speedtouchversion
661 if (-f
"/proc/bus/usb/devices")
663 $speedtouch=`/bin/cat /proc/bus/usb/devices | /bin/grep 'Vendor=06b9 ProdID=4061' | /usr/bin/cut -d ' ' -f6`;
664 if ($speedtouch eq '') {
665 $speedtouch= $Lang::tr
{'connect the modem'};
668 $speedtouch='USB '.$Lang::tr
{'not running'};
673 #Sorting of allocated leases
675 my %dhcpsettings = ();
676 &General
::readhash
("${General::swroot}/dhcp/settings", \
%dhcpsettings);
678 if ($ENV{'QUERY_STRING'} =~ /^IPADDR|^ETHER|^HOSTNAME|^ENDTIME/ ) {
679 my $newsort=$ENV{'QUERY_STRING'};
680 my $act=$dhcpsettings{'SORT_LEASELIST'};
681 #Default sort if unspecified
682 $act='IPADDRRev' if !defined ($act);
684 if ($act =~ $newsort) {
686 if ($act !~ 'Rev') {$Rev='Rev'};
690 $dhcpsettings{'SORT_LEASELIST'}=$newsort;
691 &General
::writehash
("${General::swroot}/dhcp/settings", \
%dhcpsettings);
695 sub PrintActualLeases
697 our %dhcpsettings = ();
702 if (rindex ($dhcpsettings{'SORT_LEASELIST'},'Rev') != -1)
704 $qs=substr ($dhcpsettings{'SORT_LEASELIST'},0,length($dhcpsettings{'SORT_LEASELIST'})-3);
705 if ($qs eq 'IPADDR') {
706 my @a = split(/\./,$entries{$a}->{$qs});
707 my @b = split(/\./,$entries{$b}->{$qs});
713 $entries{$b}->{$qs} cmp $entries{$a}->{$qs};
718 $qs=$dhcpsettings{'SORT_LEASELIST'};
719 if ($qs eq 'IPADDR') {
720 my @a = split(/\./,$entries{$a}->{$qs});
721 my @b = split(/\./,$entries{$b}->{$qs});
727 $entries{$a}->{$qs} cmp $entries{$b}->{$qs};
732 &Header
::openbox
('100%', 'left', $Lang::tr
{'current dynamic leases'});
736 <td width='25%' align='center'><a href='$ENV{'SCRIPT_NAME'}?IPADDR'><b>$Lang::tr{'ip address'}</b></a></td>
737 <td width='25%' align='center'><a href='$ENV{'SCRIPT_NAME'}?ETHER'><b>$Lang::tr{'mac address'}</b></a></td>
738 <td width='20%' align='center'><a href='$ENV{'SCRIPT_NAME'}?HOSTNAME'><b>$Lang::tr{'hostname'}</b></a></td>
739 <td width='30%' align='center'><a href='$ENV{'SCRIPT_NAME'}?ENDTIME'><b>$Lang::tr{'lease expires'} (local time d/m/y)</b></a></td>
744 my ($ip, $endtime, $ether, $hostname, @record, $record);
745 open(LEASES
,"/var/state/dhcp/dhcpd.leases") or die "Can't open dhcpd.leases";
746 while (my $line = <LEASES
>) {
747 next if( $line =~ /^\s*#/ );
749 my @temp = split (' ', $line);
751 if ($line =~ /^\s*lease/) {
753 #All field are not necessarily read. Clear everything
757 } elsif ($line =~ /^\s*ends never;/) {
759 } elsif ($line =~ /^\s*ends/) {
760 $line =~ /(\d+)\/(\d
+)\
/(\d+) (\d+):(\d+):(\d+)/;
761 $endtime = timegm
($6, $5, $4, $3, $2 - 1, $1 - 1900);
762 } elsif ($line =~ /^\s*hardware ethernet/) {
765 } elsif ($line =~ /^\s*client-hostname/) {
767 $hostname = join (' ',@temp);
769 $hostname =~ s/\"//g;
770 } elsif ($line eq "}") {
771 @record = ('IPADDR',$ip,'ENDTIME',$endtime,'ETHER',$ether,'HOSTNAME',$hostname);
772 $record = {}; # create a reference to empty hash
773 %{$record} = @record; # populate that hash with @record
774 $entries{$record->{'IPADDR'}} = $record; # add this to a hash of hashes
775 } #unknown format line...
780 $dhcpsettings{'SORT_LEASELIST'}='IPADDR'; #default
781 &General
::readhash
("${General::swroot}/dhcp/settings", \
%dhcpsettings); #or maybe saved !
783 foreach my $key (sort leasesort
keys %entries) {
785 my $hostname = &Header
::cleanhtml
($entries{$key}->{HOSTNAME
},"y");
788 print "<tr bgcolor='$Header::table1colour'>";
791 print "<tr bgcolor='$Header::table2colour'>";
795 <td align='center'>$entries{$key}->{IPADDR}</td>
796 <td align='center'>$entries{$key}->{ETHER}</td>
797 <td align='center'> $hostname </td>
802 if ($entries{$key}->{ENDTIME
} eq 'never') {
803 print "$Lang::tr{'no time limit'}";
805 my ($sec, $min, $hour, $mday, $mon, $year, $wday, $yday, $dst);
806 ($sec, $min, $hour, $mday, $mon, $year, $wday, $yday, $dst) = localtime ($entries{$key}->{ENDTIME
});
807 my $enddate = sprintf ("%02d/%02d/%d %02d:%02d:%02d",$mday,$mon+1,$year+1900,$hour,$min,$sec);
809 if ($entries{$key}->{ENDTIME
} < time() ){
810 print "<strike>$enddate</strike>";