Revision: 3077 http://ipcop.svn.sourceforge.net/ipcop/?rev=3077&view=rev Author: riddles Date: 2009-06-17 15:18:40 +0000 (Wed, 17 Jun 2009)
Log Message: ----------- Template dhcp.cgi and netstatus.cgi Modified Paths: -------------- ipcop/branches/template-branch/config/rootfiles/common/Template-Toolkit ipcop/branches/template-branch/html/cgi-bin/dhcp.cgi ipcop/branches/template-branch/html/cgi-bin/netstatus.cgi ipcop/branches/template-branch/src/libs/general-functions.pl Added Paths: ----------- ipcop/branches/template-branch/html/html/pages/dhcp.tpl ipcop/branches/template-branch/html/html/pages/netstatus.tpl Modified: ipcop/branches/template-branch/config/rootfiles/common/Template-Toolkit =================================================================== --- ipcop/branches/template-branch/config/rootfiles/common/Template-Toolkit 2009-06-17 15:14:05 UTC (rev 3076) +++ ipcop/branches/template-branch/config/rootfiles/common/Template-Toolkit 2009-06-17 15:18:40 UTC (rev 3077) @@ -36,7 +36,7 @@ #usr/lib/perl5/site_perl/5.8.8/MACHINE-linux/Template/Plugin/Autoformat.pm #usr/lib/perl5/site_perl/5.8.8/MACHINE-linux/Template/Plugin/CGI.pm #usr/lib/perl5/site_perl/5.8.8/MACHINE-linux/Template/Plugin/Datafile.pm -#usr/lib/perl5/site_perl/5.8.8/MACHINE-linux/Template/Plugin/Date.pm +usr/lib/perl5/site_perl/5.8.8/MACHINE-linux/Template/Plugin/Date.pm #usr/lib/perl5/site_perl/5.8.8/MACHINE-linux/Template/Plugin/Directory.pm #usr/lib/perl5/site_perl/5.8.8/MACHINE-linux/Template/Plugin/Dumper.pm #usr/lib/perl5/site_perl/5.8.8/MACHINE-linux/Template/Plugin/File.pm Modified: ipcop/branches/template-branch/html/cgi-bin/dhcp.cgi =================================================================== --- ipcop/branches/template-branch/html/cgi-bin/dhcp.cgi 2009-06-17 15:14:05 UTC (rev 3076) +++ ipcop/branches/template-branch/html/cgi-bin/dhcp.cgi 2009-06-17 15:18:40 UTC (rev 3077) @@ -25,17 +25,16 @@ # use strict; +use Template; # enable only the following on debugging purpose -#use warnings; no warnings 'once'; -#use CGI::Carp 'fatalsToBrowser'; +use warnings; no warnings 'once'; +use CGI::Carp 'fatalsToBrowser'; require '/usr/lib/ipcop/general-functions.pl'; require '/usr/lib/ipcop/lang.pl'; require '/usr/lib/ipcop/header.pl'; -&Header::showhttpheaders(); - my %dhcpsettings = (); my %netsettings = (); my %mainsettings = (); @@ -45,7 +44,6 @@ my $errormessage = ''; my $error_save_main = ''; my $error_save_fixed = ''; -my $warnmessage = ''; # owes: TODO add Blue only when defined my @INTERFACEs = ('GREEN', 'BLUE'); @@ -60,6 +58,24 @@ my $disable_main = 0; # 1 = only show (non-editable) some vital information in the main box my $disable_fixed = 1; # 1 = only show fixed leases, 0 = fields to add fixed lease become usable +my $page_vars = &Header::get_page_vars(); + +## +## Initialize Template +## +my $tt = Template->new({ + INCLUDE_PATH => '/home/httpd/html/pages:/home/httpd/html/themes', + FILTERS => { + 'loc' => \&Header::maketext, + 'color_devices' => \&General::color_devices, + }, +}) || die "$Template::ERROR\n"; + +## +## Start Page +## +&Header::showhttpheaders(); + # get IPCop settings &General::readhash('/var/ipcop/ethernet/settings', \%netsettings); &General::readhash('/var/ipcop/main/settings', \%mainsettings); @@ -92,6 +108,7 @@ $dhcpsettings{'FIXED_FILENAME'} = ''; $dhcpsettings{'FIXED_ROOTPATH'} = ''; $dhcpsettings{'KEY_FIXED'} = ''; +$dhcpsettings{'SORT_LEASELIST'} = 'IPADDR'; # read the fixed leases my @fixedleases; @@ -110,9 +127,6 @@ } } -&Header::openpage($Lang::tr{'dhcp configuration'}, 1, ''); -&Header::openbigbox('100%', 'left', '', ''); - ############### # DEBUG DEBUG if ($debug) { @@ -252,8 +266,8 @@ if ( ($dhcpsettings{"NTP1_${interface}_${counter}"} eq $netsettings{"${interface}_${counter}_ADDRESS"}) && ($timesettings{'ENABLED_NTP'} ne 'on')) { - $warnmessage = - "DHCP on ${interface}: " . $Lang::tr{'local ntp server specified but not enabled'}; + push(@{$page_vars->{'warnmessages'}}, + "DHCP on ${interface}: " . $Lang::tr{'local ntp server specified but not enabled'}); } } if ($dhcpsettings{"NTP2_${interface}_${counter}"}) { @@ -264,8 +278,8 @@ if ( ($dhcpsettings{"NTP2_${interface}_${counter}"} eq $netsettings{"${interface}_${counter}_ADDRESS"}) && ($timesettings{'ENABLED_NTP'} ne 'on')) { - $warnmessage = - "DHCP on ${interface}: " . $Lang::tr{'local ntp server specified but not enabled'}; + push(@{$page_vars->{'warnmessages'}}, + "DHCP on ${interface}: " . $Lang::tr{'local ntp server specified but not enabled'}); } if (!$dhcpsettings{"NTP1_${interface}_${counter}"}) { $errormessage = @@ -279,9 +293,13 @@ } # foreach interface &writeconfig(1); ERROR_SAVE_MAIN: - $error_save_main = 'error' if ($errormessage); + if ($errormessage) { + $error_save_main = 'error'; + push(@{$page_vars->{'errormessages'}}, $errormessage); + } } else { + &General::CheckSortOrder; &General::readhash('/var/ipcop/dhcp/settings', \%dhcpsettings); } @@ -364,10 +382,10 @@ } } } - if ($insubnet == 0) { - $errormessage = $Lang::tr{'invalid fixed ip address'}; - goto ERROR_SAVE_FIXED; - } + #if ($insubnet == 0) { + # $errormessage = $Lang::tr{'invalid fixed ip address'}; + # goto ERROR_SAVE_FIXED; + #} # TODO: test for duplicate MAC addresses # Duplicate MAC is OK, as long as the to be assigned IP addresses are in different networks @@ -396,6 +414,7 @@ $error_save_fixed = 'error'; $disable_main = 1; $disable_fixed = 0; + push(@{$page_vars->{'errormessages'}}, $errormessage); } } @@ -419,345 +438,68 @@ &writefixedleases(0); } -# -# display box with warnmessage in case of warning -# -if ($warnmessage) { - &Header::openbox('100%', 'left', $Lang::tr{'capswarning'}, 'warning'); - print "<font class='base'>$warnmessage </font>\n"; - &Header::closebox(); -} +## +## Read fixed leases +## +...@fixedleases = (); +open(FILE, '/var/ipcop/dhcp/fixedleases'); + while (<FILE>) { + chomp($_); + my @temp = split(/\,/, $_); + my %lease = ( + 'mac' => $temp[0], + 'ip' => $temp[1], + 'enabled' => $temp[2], + 'nextaddr' => $temp[3], + 'filename' => $temp[4], + 'rootpath' => $temp[5], + 'remark' => $temp[6], + 'hostname' => $temp[7], + ); + push (@fixedleases, \%lease); + } +close(FILE); -# -# display box with errormessage in case of error -# -if ($errormessage) { - &Header::openbox('100%', 'left', "$Lang::tr{'error messages'}:", 'error'); - print "<font class='base'>$errormessage </font>\n"; - &Header::closebox(); -} - -# -# display box with main settings -# -&Header::openbox('100%', 'left', "$Lang::tr{'settings'}:", $error_save_main); +## +## Display DHCP Server running +## my $sactive = &General::isrunning('dhcpd', 'nosize'); -print <<END -<form method='post' name='frm_main' action='$ENV{'SCRIPT_NAME'}'> -<table width='100%'> -<tr> - <td width='25%'>$Lang::tr{'dhcp server'}:</td> - $sactive - <td width='25%'> </td> - <td width='25%'> </td> -</tr> -</table> -<hr /> -END -; - +## +## Get Actual DHCP Leases +## +my @leases = (); +$enabled_count = 1; foreach $interface (@INTERFACEs) { for ($counter = 1; $counter <= $netsettings{"${interface}_COUNT"}; $counter++) { - my $lc_interface = lc($interface); - $checked{'ENABLED'}{'on'} = - ($dhcpsettings{"ENABLED_${interface}_${counter}"} ne 'on') ? '' : "checked='checked'"; - $checked{'ENABLED_BOOTP'}{'on'} = - ($dhcpsettings{"ENABLED_BOOTP_${interface}_${counter}"} ne 'on') ? '' : "checked='checked'"; - my $disable_text = ''; - $disable_text = "disabled='disabled'" if ($disable_main == 1); - - print <<END -<table width='100%'> -<tr> - <td width='25%' class='boldbase'><span class='ipcop_iface_$lc_interface'>$Lang::tr{"$lc_interface"}</span></td> - <td width='25%' class='base'>$Lang::tr{'enabled'}:<input type='checkbox' name='ENABLED_${interface}_${counter}' $checked{'ENABLED'}{'on'} $disable_text /></td> - <td width='25%' class='base'>$Lang::tr{'ip address'}/$Lang::tr{'netmask'}:</td> - <td width='25%' class='base'><b>$netsettings{"${interface}_${counter}_ADDRESS"}/$netsettings{"${interface}_${counter}_NETMASK"}</b></td> -</tr><tr> - <td width='25%' class='base'>$Lang::tr{'start address'}: <img src='/blob.gif' alt='*' /></td> - <td width='25%'><input type='text' name='START_ADDR_${interface}_${counter}' value='$dhcpsettings{"START_ADDR_${interface}_${counter}"}' $disable_text /></td> - <td width='25%' class='base'>$Lang::tr{'end address'}: <img src='/blob.gif' alt='*' /></td> - <td width='25%'><input type='text' name='END_ADDR_${interface}_${counter}' value='$dhcpsettings{"END_ADDR_${interface}_${counter}"}' $disable_text /></td> -</tr> -END - ; - if ($disable_main == 0) { - print <<END -<tr> - <td class='base'>$Lang::tr{'default lease time'}:</td> - <td><input type='text' name='DEFAULT_LEASE_TIME_${interface}_${counter}' value='$dhcpsettings{"DEFAULT_LEASE_TIME_${interface}_${counter}"}' size='5' /></td> - <td class='base'>$Lang::tr{'domain name suffix'}: <img src='/blob.gif' alt='*' /></td> - <td><input type='text' name='DOMAIN_NAME_${interface}_${counter}' value='$dhcpsettings{"DOMAIN_NAME_${interface}_${counter}"}' /></td> -</tr><tr> - <td>$Lang::tr{'dhcp allow bootp'}:</td> - <td><input type='checkbox' name='ENABLED_BOOTP_${interface}_${counter}' $checked{'ENABLED_BOOTP'}{'on'} /></td> - <td> </td><td> </td> -</tr><tr> - <td class='base'>$Lang::tr{'primary dns'}:</td> - <td><input type='text' name='DNS1_${interface}_${counter}' value='$dhcpsettings{"DNS1_${interface}_${counter}"}' /></td> - <td class='base'>$Lang::tr{'secondary dns'}: <img src='/blob.gif' alt='*' /></td> - <td><input type='text' name='DNS2_${interface}_${counter}' value='$dhcpsettings{"DNS2_${interface}_${counter}"}' /></td> -</tr><tr> - <td class='base'>$Lang::tr{'primary ntp server'}: <img src='/blob.gif' alt='*' /></td> - <td><input type='text' name='NTP1_${interface}_${counter}' value='$dhcpsettings{"NTP1_${interface}_${counter}"}' /></td> - <td class='base'>$Lang::tr{'secondary ntp server'}: <img src='/blob.gif' alt='*' /></td> - <td><input type='text' name='NTP2_${interface}_${counter}' value='$dhcpsettings{"NTP2_${interface}_${counter}"}' /></td> -</tr><tr> - <td class='base'>$Lang::tr{'primary wins server address'}: <img src='/blob.gif' alt='*' /></td> - <td><input type='text' name='WINS1_${interface}_${counter}' value='$dhcpsettings{"WINS1_${interface}_${counter}"}' /></td> - <td class='base'>$Lang::tr{'secondary wins server address'}: <img src='/blob.gif' alt='*' /></td> - <td><input type='text' name='WINS2_${interface}_${counter}' value='$dhcpsettings{"WINS2_${interface}_${counter}"}' /></td> -</tr> -END - ; - } - print "</table><hr />"; - } -} - -if ($disable_main == 1) { - print "</form>"; -} -else { - print <<END -<table width='100%'> -<tr> - <td class='comment1button'><img src='/blob.gif' align='top' alt='*' /> $Lang::tr{'this field may be blank'}</td> - <td class='button1button'><input type='hidden' name='ACTION' value='SAVE_MAIN' /><input type='submit' name='SUBMIT' value='$Lang::tr{'save'}' /></td> - <td class='button1button'> - <a href='${General::adminmanualurl}/services-dhcp.html' target='_blank'> - <img src='/images/web-support.png' alt='$Lang::tr{'online help en'}' title='$Lang::tr{'online help en'}' /></a></td> -</tr> -</table> -</form> -END - ; -} -&Header::closebox(); - -# -# display box with fixed leases -# - -if ($disable_fixed == 0) { - $checked{'FIXED_ENABLED'}{'on'} = ($dhcpsettings{'FIXED_ENABLED'} ne 'on') ? '' : "checked='checked'"; - - # if KEY_FIXED is set, this is edit/update not add - - if ($dhcpsettings{'KEY_FIXED'} ne '') { - $buttontext = $Lang::tr{'update'}; - &Header::openbox('100%', 'left', "$Lang::tr{'edit an existing lease'}:", $error_save_fixed); - } - else { - &Header::openbox('100%', 'left', "$Lang::tr{'add new lease'}:", $error_save_fixed); - } - - print <<END -<form method='post' name='frm_fixed' action='$ENV{'SCRIPT_NAME'}'> -<table width='100%' border='0'> -<tr> - <td class='base'>$Lang::tr{'enabled'}:</td> - <td><input type='checkbox' name='FIXED_ENABLED' $checked{'FIXED_ENABLED'}{'on'} /></td> - <td colspan='2'> </td> -</tr><tr> - <td width='25%' class='base'>$Lang::tr{'mac address'}:</td> - <td width='25%'><input type='text' name='FIXED_MAC' value='$dhcpsettings{'FIXED_MAC'}' size='18' /></td> - <td width='25%' class='base'>$Lang::tr{'ip address'}:</td> - <td width='25%'><input type='text' name='FIXED_IP' value='$dhcpsettings{'FIXED_IP'}' size='18' /></td> -</tr><tr> - <td class='base'>$Lang::tr{'hostname'} $Lang::tr{'or'} FQDN: <img src='/blob.gif' alt='*' /></td> - <td colspan='3'><input type='text' name='FIXED_HOSTNAME' value='$dhcpsettings{'FIXED_HOSTNAME'}' size='40' /></td> -</tr><tr> - <td width='25%' class='base'>$Lang::tr{'remark'}: <img src='/blob.gif' alt='*' /></td> - <td colspan='3'><input type='text' name='FIXED_REMARK' value='$dhcpsettings{'FIXED_REMARK'}' size='40' /></td> -</tr><tr> - <td colspan = '4'><b>$Lang::tr{'dhcp bootp pxe data'}</b></td> -</tr><tr> - <td class='base'>filename: <img src='/blob.gif' alt='*' /></td> - <td><input type='text' name='FIXED_FILENAME' value='$dhcpsettings{'FIXED_FILENAME'}' size='18' /></td> - <td class='base'>root-path: <img src='/blob.gif' alt='*' /></td> - <td><input type='text' name='FIXED_ROOTPATH' value='$dhcpsettings{'FIXED_ROOTPATH'}' size='18' /></td> -</tr><tr> - <td class='base'>next-server: <img src='/blob.gif' alt='*' /></td> - <td><input type='text' name='FIXED_NEXTADDR' value='$dhcpsettings{'FIXED_NEXTADDR'}' size='18' /></td> - <td colspan='2'> </td> -</tr> -</table> -<hr /> -<table width='100%'> -<tr> - <td class='comment1button'><img src='/blob.gif' align='top' alt='*' /> $Lang::tr{'this field may be blank'} - $Lang::tr{'dhcp fixed lease help1'}</td> - <td class='button1button'><input type='hidden' name='ACTION' value='SAVE_FIXED_LEASE' /> - <input type='hidden' name='KEY_FIXED' value='$dhcpsettings{'KEY_FIXED'}' /> - <input type='submit' name='SUBMIT' value='$buttontext' /></td> - <td class='onlinehelp'> </td> -</tr> -</table> -</form> -END - ; -} -else { - &Header::openbox('100%', 'left', "$Lang::tr{'current fixed leases'}:", $error_save_fixed); - - print <<END -<form method='post' name='frm_fixed_add' action='$ENV{'SCRIPT_NAME'}'> -<table width='100%'> -<tr> - <td class='comment1button'> </td> - <td class='button1button'> - <img src='/images/null.gif' width='21' height='1' alt='' /> - <input type='hidden' name='ACTION' value='ADD_FIXED_LEASE' /> - <input type='submit' name='SUBMIT' value='$Lang::tr{'add new lease'}' /> - <td class='onlinehelp'> </td> -</tr> -</table> - -</form> -END - ; -} - -# Add visual indicators to column headings to show sort order - EO -my $sortarrow1 = ''; -my $sortarrow2 = ''; - -if ($dhcpsettings{'SORT_FIXEDLEASELIST'} eq 'FIXEDMACRev') { - $sortarrow1 = $Header::sortdn; -} -elsif ($dhcpsettings{'SORT_FIXEDLEASELIST'} eq 'FIXEDMAC') { - $sortarrow1 = $Header::sortup; -} -elsif ($dhcpsettings{'SORT_FIXEDLEASELIST'} eq 'FIXEDIPRev') { - $sortarrow2 = $Header::sortdn; -} -else { - $sortarrow2 = $Header::sortup; -} - -print <<END -<hr /><table width='100%'> -<tr> - <td width='13%' align='center' nowrap='nowrap'><a href='$ENV{'SCRIPT_NAME'}?FIXEDMAC'><b>$Lang::tr{'mac address'}</b></a> $sortarrow1</td> - <td width='13%' align='center' nowrap='nowrap'><a href='$ENV{'SCRIPT_NAME'}?FIXEDIP'><b>$Lang::tr{'ip address'}</b></a> $sortarrow2</td> - <td width='14%' class='boldbase' align='center'><b>$Lang::tr{'hostname'}</b></td> - <td width='15%' align='center'><b>$Lang::tr{'remark'}</b></td> - <td width='15%' class='boldbase' align='center'><b>next-server</b></td> - <td width='15%' class='boldbase' align='center'><b>filename</b></td> - <td width='15%' class='boldbase' align='center'><b>root-path</b></td> - <td colspan='3' class='boldbase' align='center'><b>$Lang::tr{'action'}</b></td> -</tr> -END - ; - -$key = 0; -foreach $line (@fixedleases) { - my $gif = ''; - my $gdesc = ''; - - chomp($line); - my @temp = split(/\,/, $line); - - if ($temp[2] eq "on") { - $gif = 'on.gif'; - $gdesc = $Lang::tr{'click to disable'}; - } - else { - $gif = 'off.gif'; - $gdesc = $Lang::tr{'click to enable'}; - } - - if ($dhcpsettings{'KEY_FIXED'} eq $key) { - print "<tr class='selectcolour'>"; - } - else { - print "<tr class='table".int(($key % 2) + 1)."colour'>"; - } - print <<END -<td align='center'>$temp[0]</td> -<td align='center'>$temp[1]</td> -<td align='center'>$temp[7] </td> -<td align='center'>$temp[6] </td> -<td align='center'>$temp[3] </td> -<td align='center'>$temp[4] </td> -<td align='center'>$temp[5] </td> - -<td align='center'> - <form method='post' name='frm_fixed_ted_$key' action='$ENV{'SCRIPT_NAME'}'> - <input type='hidden' name='ACTION' value='$Lang::tr{'toggle enable disable'}_fixed' /> - <input type='image' name='$Lang::tr{'toggle enable disable'}' src='/images/$gif' alt='$gdesc' title='$gdesc' /> - <input type='hidden' name='KEY_FIXED' value='$key' /> - </form> -</td> - -<td align='center'> - <form method='post' name='frm_fixed_e_$key' action='$ENV{'SCRIPT_NAME'}'> - <input type='hidden' name='ACTION' value='$Lang::tr{'edit'}_fixed' /> - <input type='image' name='$Lang::tr{'edit'}' src='/images/edit.gif' alt='$Lang::tr{'edit'}' title='$Lang::tr{'edit'}' /> - <input type='hidden' name='KEY_FIXED' value='$key' /> - </form> -</td> - -<td align='center'> - <form method='post' name='frm_fixed_r_$key' action='$ENV{'SCRIPT_NAME'}'> - <input type='hidden' name='ACTION' value='$Lang::tr{'remove'}_fixed' /> - <input type='image' name='$Lang::tr{'remove'}' src='/images/delete.gif' alt='$Lang::tr{'remove'}' title='$Lang::tr{'remove'}' /> - <input type='hidden' name='KEY_FIXED' value='$key' /> - </form> -</td> -</tr> -END - ; - $key++; -} # for all fixed leases - -print "</table>"; - -# If the fixed leases file contains entries, print a legend -if ($key && $disable_fixed) { - print <<END -<table> -<tr> - <td class='boldbase'> <b>$Lang::tr{'legend'}: </b></td> - <td><img src='/images/on.gif' alt='$Lang::tr{'click to disable'}' /></td> - <td class='base'>$Lang::tr{'click to disable'}</td> - <td> </td> - <td><img src='/images/off.gif' alt='$Lang::tr{'click to enable'}' /></td> - <td class='base'>$Lang::tr{'click to enable'}</td> - <td> </td> - <td><img src='/images/edit.gif' alt='$Lang::tr{'edit'}' /></td> - <td class='base'>$Lang::tr{'edit'}</td> - <td> </td> - <td><img src='/images/delete.gif' alt='$Lang::tr{'remove'}' /></td> - <td class='base'>$Lang::tr{'remove'}</td> -</tr> -</table> -END - ; -} - -&Header::closebox(); - -# -# display box with dynamic leases if we have one or more enabled interface(s) -# -$enabled_count = 0; -foreach $interface (@INTERFACEs) { - for ($counter = 1; $counter <= $netsettings{"${interface}_COUNT"}; $counter++) { if ($dhcpsettings{"ENABLED_${interface}_${counter}"} eq 'on') { $enabled_count++; } } } if ($enabled_count > 0) { - &General::PrintActualLeases; + &General::GetActualLeases(\...@leases); } -&Header::closebigbox(); -&Header::closepage(); +## +## Process Template and Exit +## +$tt->process('dhcp.tpl', { + 'page' => $page_vars, + 'system' => \&Header::get_system_vars, + 'error_main' => $error_save_main, + 'error_fixed' => $error_save_fixed, + 'interfaces' => \...@interfaces, + 'dhcpsettings' => \%dhcpsettings, + 'netsettings' => \%netsettings, + 'disable_main' => $disable_main, + 'disable_fixed' => $disable_fixed, + 'sactive' => $sactive, + 'leases' => \...@leases, + 'fixedleases' => \...@fixedleases, +}) || die $tt->error(), "\n"; + # # write config files, dhcpd.conf etc. # Modified: ipcop/branches/template-branch/html/cgi-bin/netstatus.cgi =================================================================== --- ipcop/branches/template-branch/html/cgi-bin/netstatus.cgi 2009-06-17 15:14:05 UTC (rev 3076) +++ ipcop/branches/template-branch/html/cgi-bin/netstatus.cgi 2009-06-17 15:18:40 UTC (rev 3077) @@ -10,6 +10,7 @@ # use strict; +use Template; # enable only the following on debugging purpose #use warnings; @@ -19,173 +20,139 @@ require '/usr/lib/ipcop/lang.pl'; require '/usr/lib/ipcop/header.pl'; -my %dhcpsettings=(); -my %netsettings=(); -my %dhcpinfo=(); -my %pppsettings=(); -my $output=''; -$dhcpinfo{'DOMAIN'}=''; # because it may not be defined in the answer -my $dhcpserver = 0; +my %dhcpsettings = (); +my %netsettings = (); +my %dhcpinfo = (); +my %pppsettings = (); +$dhcpinfo{'DOMAIN'} = ''; # because it may not be defined in the answer +my $dhcpserver = 0; +my $page_vars = &Header::get_page_vars(); +## +## Initialize Template +## +my $tt = Template->new({ + INCLUDE_PATH => '/home/httpd/html/pages:/home/httpd/html/themes', + FILTERS => { + 'loc' => \&Header::maketext, + 'color_devices' => \&General::color_devices, + }, +}) || die "$Template::ERROR\n"; + +## +## Start Page +## +&General::CheckSortOrder; &General::readhash('/var/ipcop/dhcp/settings', \%dhcpsettings); &General::readhash('/var/ipcop/ethernet/settings', \%netsettings); &General::readhash('/var/ipcop/ppp/settings', \%pppsettings); &Header::showhttpheaders(); -&Header::openpage($Lang::tr{'network status information'}, 1, ''); -my @DHCPINTERFACEs=('GREEN','BLUE'); -foreach my $interface (@DHCPINTERFACEs) { - for (my $counter = 1; $counter <= $netsettings{"${interface}_COUNT"}; $counter++) { - if ( $dhcpsettings{"ENABLED_${interface}_${counter}"} eq 'on' ) { - $dhcpserver++; - } - } -} +## +## Interfaces +## +my $interfaces = `/sbin/ifconfig -a`; +$interfaces = &General::color_devices($interfaces); -&Header::openbigbox('100%', 'left'); - -print "<table width='100%' cellspacing='0' cellpadding='5'border='0'>\n"; -print "<tr><td style='background-color: #FFFFFF;' align='left'>\n"; -print "<a href='#interfaces'>$Lang::tr{'interfaces'}:</a> |\n"; -if ( ($netsettings{'RED_COUNT'} >= 1) && $netsettings{'RED_1_TYPE'} eq "DHCP") { - print "<a href='#reddhcp'>RED $Lang::tr{'dhcp configuration'}:</a> |\n"; -} -if ($dhcpserver > 0) { - print "<a href='#leases'>$Lang::tr{'current dynamic leases'}:</a> |\n"; -} -if ($pppsettings{'TYPE'} =~ /^(bewanadsl|alcatelusbk|conexantpciadsl|eagleusbadsl|wanpipe)$/) { - print "<a href='#adsl'>$Lang::tr{'adsl settings'}</a> |\n"; -} -print "<a href='#routing'>$Lang::tr{'routing table entries'}:</a> |\n"; -print "<a href='#arp'> $Lang::tr{'arp table entries'}:</a>\n"; -print "</td></tr></table>\n"; - -print "<a name='interfaces'/>\n"; -&Header::openbox('100%', 'left', "$Lang::tr{'interfaces'}:"); -$output = `/sbin/ifconfig -a`; -$output = &General::color_devices($output); -print "<pre>$output</pre>\n"; -&Header::closebox(); - - +## +## RED DHCP +## if ( ($netsettings{'RED_COUNT'} >= 1) && $netsettings{'RED_1_TYPE'} eq "DHCP") { - - print "<a name='reddhcp'/>\n"; - &Header::openbox('100%', 'left', "RED $Lang::tr{'dhcp configuration'}:"); if (-s "/var/log/dhcpclient.info") { - &General::readhash("/var/log/dhcpclient.info", \%dhcpinfo); - my $lsetme=0; - my $leasetime=""; + $dhcpinfo{'leasetime'}=""; if ($dhcpinfo{'DHCLIENT_LEASETIME'} ne "") { $lsetme=$dhcpinfo{'DHCLIENT_LEASETIME'}; $lsetme=($lsetme/60); if ($lsetme > 59) { - $lsetme=($lsetme/60); $leasetime=$lsetme." Hour"; + $lsetme=($lsetme/60); $dhcpinfo{'leasetime'}=$lsetme." Hour"; } else { - $leasetime=$lsetme." Minute"; + $dhcpinfo{'leasetime'}=$lsetme." Minute"; } if ($lsetme > 1) { - $leasetime=$leasetime."s"; + $dhcpinfo{'leasetime'}=$dhcpinfo{'leasetime'}."s"; } } - my $leaseexpires = localtime($dhcpinfo{'DHCLIENT_EXPIRY'}); + $dhcpinfo{'leaseexpires'} = localtime($dhcpinfo{'DHCLIENT_EXPIRY'}); + } +} - print "<table width='100%'>"; - if ($dhcpinfo{'DHCLIENT_HOSTNAME'}) { - print "<tr><td width='30%'>$Lang::tr{'hostname'}:</td><td>$dhcpinfo{'DHCLIENT_HOSTNAME'}.$dhcpinfo{'DHCLIENT_DOMAIN'}</td></tr>\n"; - } - else { - print "<tr><td width='30%'>$Lang::tr{'domain'}:</td><td>$dhcpinfo{'DHCLIENT_DOMAIN'}</td></tr>\n"; +## +## DHCP Server +## +my @DHCPINTERFACEs=('GREEN','BLUE'); +foreach my $interface (@DHCPINTERFACEs) { + for (my $counter = 1; $counter <= $netsettings{"${interface}_COUNT"}; $counter++) { + if ( $dhcpsettings{"ENABLED_${interface}_${counter}"} eq 'on' ) { + $dhcpserver++; } - print <<END - <tr><td>$Lang::tr{'gateway'}:</td><td>$dhcpinfo{'DHCLIENT_GATEWAY'}</td></tr> - <tr><td>$Lang::tr{'primary dns'}:</td><td>$dhcpinfo{'DHCLIENT_DNS1'}</td></tr> - <tr><td>$Lang::tr{'secondary dns'}:</td><td>$dhcpinfo{'DHCLIENT_DNS2'}</td></tr> - <tr><td>$Lang::tr{'dhcp server'}:</td><td>$dhcpinfo{'DHCLIENT_SIADDR'}</td></tr> - <tr><td>$Lang::tr{'def lease time'}:</td><td>$leasetime</td></tr> - <tr><td>$Lang::tr{'lease expires'}:</td><td>$leaseexpires</td></tr> -</table> -END - ; } - else { - print "$Lang::tr{'no dhcp lease'}"; - } - &Header::closebox(); } -if ($dhcpserver > 0) { - print "<a name='leases'/>"; - &General::CheckSortOrder; - &General::PrintActualLeases; -} +my @leases = (); +#if ($dhcpserver > 0) { + &General::GetActualLeases(\...@leases); +#} +## +## ADSL Settings / Status +## +my $adsl = ''; if ( ($netsettings{'RED_COUNT'} == 0) && (exists($pppsettings{'TYPE'})) ) { - my $output1=''; - my $output2=''; if ($pppsettings{'TYPE'} eq 'bewanadsl') { - print "<a name='adsl'/>\n"; - &Header::openbox('100%', 'left', "$Lang::tr{'adsl settings'}:"); + my $output1=''; + my $output2=''; $output1 = `/usr/bin/unicorn_status`; $output1 = &Header::cleanhtml($output1,"y"); $output2 = `/bin/cat /proc/net/atm/UNICORN:*`; $output2 = &Header::cleanhtml($output2,"y"); - print "<pre>$output1$output2</pre>\n"; - &Header::closebox(); + $adsl = $output1 . $output2; } if ($pppsettings{'TYPE'} eq 'alcatelusbk') { - print "<a name='adsl'/>\n"; - &Header::openbox('100%', 'left', "$Lang::tr{'adsl settings'}:"); - $output = `/bin/cat /proc/net/atm/speedtch:*`; - $output = &Header::cleanhtml($output,"y"); - print "<pre>$output</pre>\n"; - &Header::closebox(); + $adsl = `/bin/cat /proc/net/atm/speedtch:*`; + $adsl = &Header::cleanhtml($adsl,"y"); } if ($pppsettings{'TYPE'} eq 'conexantpciadsl') { - print "<a name='adsl'/>\n"; - &Header::openbox('100%', 'left', "$Lang::tr{'adsl settings'}:"); - $output = `/bin/cat /proc/net/atm/CnxAdsl:*`; - $output = &Header::cleanhtml($output,"y"); - print "<pre>$output</pre>\n"; - &Header::closebox(); + $adsl = `/bin/cat /proc/net/atm/CnxAdsl:*`; + $adsl = &Header::cleanhtml($adsl,"y"); } if ($pppsettings{'TYPE'} eq 'eagleusbadsl') { - print "<a name='adsl'/>\n"; - &Header::openbox('100%', 'left', "$Lang::tr{'adsl settings'}:"); - $output = `/usr/sbin/eaglestat`; - $output = &Header::cleanhtml($output,"y"); - print "<pre>$output</pre>\n"; - &Header::closebox(); + $adsl = `/usr/sbin/eaglestat`; + $adsl = &Header::cleanhtml($adsl,"y"); } if ($pppsettings{'TYPE'} eq 'wanpipe') { - print "<a name='adsl'/>\n"; - &Header::openbox('100%', 'left', "$Lang::tr{'adsl settings'}:"); - $output = `/bin/cat /proc/net/wanrouter/config | /usr/bin/sort`; - $output = &Header::cleanhtml($output,"y"); - print "<pre>$output</pre>\n"; - &Header::closebox(); + $adsl = `/bin/cat /proc/net/wanrouter/config | /usr/bin/sort`; + $adsl = &Header::cleanhtml($adsl,"y"); } } -print "<a name='routing'/>\n"; -&Header::openbox('100%', 'left', "$Lang::tr{'routing table entries'}:"); -$output = `/sbin/route -n`; -$output = &Header::cleanhtml($output,"y"); -$output = &General::color_devices($output); -print "<pre>$output</pre>\n"; -&Header::closebox(); +## +## Routing table +## +my $route = `/sbin/route -n`; +$route = &Header::cleanhtml($route,"y"); -print "<a name='arp'/>\n"; -&Header::openbox('100%', 'left', "$Lang::tr{'arp table entries'}:"); -$output = `/sbin/arp -n`; -$output = &Header::cleanhtml($output,"y"); -$output = &General::color_devices($output); -print "<pre>$output</pre>\n"; -&Header::closebox(); +## +## ARP Table +## +my $arp = `/sbin/arp -n`; +$arp = &Header::cleanhtml($arp,"y"); -&Header::closebigbox(); - -&Header::closepage(); +## +## Process Template and Exit +## +$tt->process('netstatus.tpl', { + 'page' => $page_vars, + 'system' => \&Header::get_system_vars, + 'dhcpserver' => $dhcpserver, + 'dhcpsettings'=> \%dhcpsettings, + 'pppsettings' => \%pppsettings, + 'netsettings' => \%netsettings, + 'interfaces' => $interfaces, + 'leases' => \...@leases, + 'adsl' => $adsl, + 'route' => $route, + 'arp' => $arp, +}) || die $tt->error(), "\n"; Added: ipcop/branches/template-branch/html/html/pages/dhcp.tpl =================================================================== --- ipcop/branches/template-branch/html/html/pages/dhcp.tpl (rev 0) +++ ipcop/branches/template-branch/html/html/pages/dhcp.tpl 2009-06-17 15:18:40 UTC (rev 3077) @@ -0,0 +1,331 @@ +[% location = 'alt services' | loc %] +[% sublocation = 'dhcp server' | loc %] +[% title = 'dhcp configuration' | loc %] + +[% PROCESS "$page.theme/vars.tpl" %] +[% INCLUDE "$page.theme/header.tpl" %] +[% INCLUDE "$page.theme/openbigbox.tpl" + width = '100%' + align = 'left' %] + +[% INCLUDE "$page.theme/errorbox.tpl" %] +[% INCLUDE "$page.theme/warningbox.tpl" %] + +[% caption = 'settings' FILTER loc %] +[% boxframe = error_main %] +[% INCLUDE "$page.theme/openbox.tpl" + width = '100%' + align = 'left' + caption = caption + boxframe = boxframe %] +<form method='post' name='frm_main' action='[% page.url %]'> +<table width='100%'> +<tr> + <td width='25%'>[% 'dhcp server' | loc %]:</td> + [% sactive %] + <td width='25%'> </td> + <td width='25%'> </td> +</tr> +</table> +<hr /> +[% FOREACH interface IN interfaces %] + [% interface_count = interface _ "_COUNT" %] + [% FOREACH count IN [ 1 .. netsettings.${interface_count} ] %] + [% lc_interface = interface | lower %] + [% disable_text = 'disabled=\'disabled\'' IF disable_main %] + + <table width='100%'> + <tr> + [% enabled_interface_count = 'ENABLED_' _ interface _ '_' _ count %] + <td width='25%' class='boldbase'><span class='ipcop_iface_[% lc_interface %]'>[% lc_interface | loc %]</span></td> + <td width='25%' class='base'>[% 'enabled' | loc %]:<input type='checkbox' name='ENABLED_[% interface %]_[% count %]' [% 'checked=\'checked\'' IF dhcpsettings.${enabled_interface_count} == 'on' %] [% disable_text %] /></td> + <td width='25%' class='base'>[% 'ip address' | loc %]/[% 'netmask' | loc %]:</td> + [% interface_count_address = interface _ '_' _ count _ '_ADDRESS' %] + [% interface_count_netmask = interface _ '_' _ count _ '_NETMASK' %] + <td width='25%' class='base'><b>[% netsettings.${interface_count_address} %]/[% netsettings.${interface_count_netmask} %]</b></td> + </tr><tr> + [% start_addr_interface_count = 'START_ADDR_' _ interface _ '_' _ count %] + <td width='25%' class='base'>[% 'start address' | loc %]: <img src='/blob.gif' alt='*' /></td> + <td width='25%'><input type='text' name='START_ADDR_[% interface %]_[% count %]' value='[% dhcpsettings.${start_addr_interface_count} %]' [% disable_text %] /></td> + [% end_addr_interface_count = 'END_ADDR_' _ interface _ '_' _ count %] + <td width='25%' class='base'>[% 'end address' | loc %]: <img src='/blob.gif' alt='*' /></td> + <td width='25%'><input type='text' name='END_ADDR_[% interface %]_[% count %]' value='[% dhcpsettings.${end_addr_interface_count} %]' [% disable_text %] /></td> + </tr> + [% IF disable_main == 0 %] + <tr> + [% default_lease_time_interface_count = 'DEFAULT_LEASE_TIME_' _ interface _ '_' _ count %] + <td class='base'>[% 'default lease time' | loc %]:</td> + <td><input type='text' name='DEFAULT_LEASE_TIME_[% interface %]_[% count %]' value='[% dhcpsettings.${default_lease_time_interface_count} %]' size='5' /></td> + [% domain_name_interface_count = 'DOMAIN_NAME_' _ interface _ '_' _ count %] + <td class='base'>[% 'domain name suffix' | loc %]: <img src='/blob.gif' alt='*' /></td> + <td><input type='text' name='DOMAIN_NAME_[% interface %]_[% count %]' value='[% dhcpsettings.${domain_name_interface_count} %]' /></td> + </tr><tr> + [% enabled_bootp_interface_count = 'ENABLED_BOOTP_' _ interface _ '_' _ count %] + <td>[% 'dhcp allow bootp' | loc %]:</td> + <td><input type='checkbox' name='ENABLED_BOOTP_[% interface %]_[% count %]' [% 'checked=\'checked\'' IF dhcpsettings.${enabled_bootp_interface_count} == 'on' %] /></td> + <td> </td><td> </td> + </tr><tr> + [% dns1_interface_count = 'DNS1_' _ interface _ '_' _ count %] + <td class='base'>[% 'primary dns' | loc %]:</td> + <td><input type='text' name='DNS1_[% interface %]_[% count %]' value='[% dhcpsettings.${dns1_interface_count} %]' /></td> + [% dns2_interface_count = 'DNS2_' _ interface _ '_' _ count %] + <td class='base'>[% 'secondary dns' | loc %]: <img src='/blob.gif' alt='*' /></td> + <td><input type='text' name='DNS2_[% interface %]_[% count %]' value='[% dhcpsettings.${dns2_interface_count} %]' /></td> + </tr><tr> + [% ntp1_interface_count = 'NTP1_' _ interface _ '_' _ count %] + <td class='base'>[% 'primary ntp server' | loc %]: <img src='/blob.gif' alt='*' /></td> + <td><input type='text' name='NTP1_[% interface %]_[% count %]' value='[% dhcpsettings.${ntp1_interface_count} %]' /></td> + [% ntp2_interface_count = 'NTP2_' _ interface _ '_' _ count %] + <td class='base'>[% 'secondary ntp server' | loc %]: <img src='/blob.gif' alt='*' /></td> + <td><input type='text' name='NTP2_[% interface %]_[% count %]' value='[% dhcpsettings.${ntp2_interface_count} %]' /></td> + </tr><tr> + [% wins1_interface_count = 'WINS1_' _ interface _ '_' _ count %] + <td class='base'>[% 'primary wins server address' | loc %]: <img src='/blob.gif' alt='*' /></td> + <td><input type='text' name='WINS1_[% interface %]_[% count %]' value='[% dhcpsettings.${wins1_interface_count} %]' /></td> + [% wins2_interface_count = 'WINS2_' _ interface _ '_' _ count %] + <td class='base'>[% 'secondary wins server address' | loc %]: <img src='/blob.gif' alt='*' /></td> + <td><input type='text' name='WINS2_[% interface %]_[% count %]' value='[% dhcpsettings.${wins2_interface_count} %]' /></td> + </tr> + [% END %] + </table><hr /> + [% END %] +[% END %] + +[% IF disable_main == 1 %] + </form> +[% ELSE %] + <table width='100%'> + <tr> + <td class='comment1button'><img src='/blob.gif' align='top' alt='*' /> [% 'this field may be blank' | loc %]</td> + <td class='button1button'><input type='hidden' name='ACTION' value='SAVE_MAIN' /><input type='submit' name='SUBMIT' value='[% 'save' | loc %]' /></td> + <td class='button1button'> + <a href='[% system.adminmanualurl %]/services-dhcp.html' target='_blank'> + <img src='/images/web-support.png' alt='[% 'online help en' | loc %]' title='[% 'online help en' | loc %]' /></a></td> + </tr> +</table> +</form> +[% END %] +[% INCLUDE "$page.theme/closebox.tpl" %] + +[% boxframe = error_fixed %] +[% IF disable_fixed == 0 %] + [% IF dhcpsettings.KEY_FIXED != '' %] + [% buttontext = 'update' FILTER loc %] + [% caption = 'edit an existing lease' FILTER loc %] + [% ELSE %] + [% buttontext = 'add' FILTER loc %] + [% caption = 'add new lease' FILTER loc %] + [% END %] + [% INCLUDE "$page.theme/openbox.tpl" + width = '100%' + align = 'left' + caption = caption _ ':' + boxframe = boxframe %] + + <form method='post' name='frm_fixed' action='[% page.url %]'> + <table width='100%' border='0'> + <tr> + <td class='base'>[% 'enabled' | loc %]:</td> + <td><input type='checkbox' name='FIXED_ENABLED' [% 'checked=\'checked\'' IF dhcpsettings.FIXED_ENABLED == 'on' %]/></td> + <td colspan='2'> </td> + </tr><tr> + <td width='25%' class='base'>[% 'mac address' | loc %]:</td> + <td width='25%'><input type='text' name='FIXED_MAC' value='[% dhcpsettings.FIXED_MAC %]' size='18' /></td> + <td width='25%' class='base'>[% 'ip address' | loc %]:</td> + <td width='25%'><input type='text' name='FIXED_IP' value='[% dhcpsettings.FIXED_IP %]' size='18' /></td> + </tr><tr> + <td class='base'>[% 'hostname' | loc %] [% 'or' | loc %] FQDN: <img src='/blob.gif' alt='*' /></td> + <td colspan='3'><input type='text' name='FIXED_HOSTNAME' value='[% dhcpsettings.FIXED_HOSTNAME %]' size='40' /></td> + </tr><tr> + <td width='25%' class='base'>[% 'remark' | loc %]: <img src='/blob.gif' alt='*' /></td> + <td colspan='3'><input type='text' name='FIXED_REMARK' value='[% dhcpsettings.FIXED_REMARK %]' size='40' /></td> + </tr><tr> + <td colspan = '4'><b>[% 'dhcp bootp pxe data' | loc %]</b></td> + </tr><tr> + <td class='base'>filename: <img src='/blob.gif' alt='*' /></td> + <td><input type='text' name='FIXED_FILENAME' value='[% dhcpsettings.FIXED_FILENAME %]' size='18' /></td> + <td class='base'>root-path: <img src='/blob.gif' alt='*' /></td> + <td><input type='text' name='FIXED_ROOTPATH' value='[% dhcpsettings.FIXED_ROOTPATH %]' size='18' /></td> + </tr><tr> + <td class='base'>next-server: <img src='/blob.gif' alt='*' /></td> + <td><input type='text' name='FIXED_NEXTADDR' value='[% dhcpsettings.FIXED_NEXTADDR %]' size='18' /></td> + <td colspan='2'> </td> + </tr> + </table><hr /> + <table width='100%'> + <tr> + <td class='comment1button'><img src='/blob.gif' align='top' alt='*' /> [% 'this field may be blank' | loc %] + [% 'dhcp fixed lease help1' | loc %]</td> + <td class='button1button'><input type='hidden' name='ACTION' value='SAVE_FIXED_LEASE' /> + <input type='hidden' name='KEY_FIXED' value='[% dhcpsettings.KEY_FIXED %]' /> + <input type='submit' name='SUBMIT' value='[% buttontext %]' /></td> + <td class='onlinehelp'> </td> + </tr> + </table> + </form> +[% ELSE %] + [% caption = 'current fixed leases' FILTER loc %] + [% INCLUDE "$page.theme/openbox.tpl" + width = '100%' + align = 'left' + caption = caption _ ':' + boxframe = boxframe %] + + <form method='post' name='frm_fixed_add' action='[% page.url %]'> + <table width='100%'> + <tr> + <td class='comment1button'> </td> + <td class='button1button'> + <img src='/images/null.gif' width='21' height='1' alt='' /> + <input type='hidden' name='ACTION' value='ADD_FIXED_LEASE' /> + <input type='submit' name='SUBMIT' value='[% 'add new lease' | loc %]' /> + <td class='onlinehelp'> </td> + </tr> + </table> + + </form> +[% END %] + +[% IF dhcpsettings.SORT_FIXEDLEASELIST == 'FIXEDMACRev' %] + [% sortarrow1 = mytheme.srtdn %] + [% sortarrow2 = '' %] +[% ELSIF dhcpsettings.SORT_FIXEDLEASELIST == 'FIXEDMAC' %] + [% sortarrow1 = mytheme.sortup %] + [% sortarrow2 = '' %] +[% ELSIF dhcpsettings.SORT_FIXEDLEASELIST == 'FIXEDIPRev' %] + [% sortarrow1 = '' %] + [% sortarrow2 = mytheme.sortdn %] +[% ELSE %] + [% sortarrow1 = '' %] + [% sortarrow2 = mytheme.sortup %] +[% END %] +<hr /><table width='100%'> +<tr> + <td width='13%' align='center' nowrap='nowrap'><a href='[% page.url %]?FIXEDMAC'><b>[% 'mac address' | loc %]</b></a> [% sortarrow1 %]</td> + <td width='13%' align='center' nowrap='nowrap'><a href='[% page.url %]?FIXEDIP'><b>[% 'ip address' | loc %]</b></a> [% sortarrow2 %]</td> + <td width='14%' class='boldbase' align='center'><b>[% 'hostname' | loc %]</b></td> + <td width='15%' align='center'><b>[% 'remark' | loc %]</b></td> + <td width='15%' class='boldbase' align='center'><b>next-server</b></td> + <td width='15%' class='boldbase' align='center'><b>filename</b></td> + <td width='15%' class='boldbase' align='center'><b>root-path</b></td> + <td colspan='3' class='boldbase' align='center'><b>[% 'action' | loc %]</b></td> +</tr> + +[% FOREACH lease IN fixedleases %] + [% IF lease.enabled == 'on' %] + [% gif = 'on.gif' %] + [% gdesc = 'click to disable' FILTER loc %] + [% ELSE %] + [% gif = 'off.gif' %] + [% gdesc = 'click to enable' FILTER loc %] + [% END %] + + [% IF loop.index == dhcpsettings.KEY_FIXED %] + <tr class='selectcolour'> + [% ELSE %] + <tr class='table[% (loop.index % 2) + 1 %]colour'> + [% END %] + + <td align='center'>[% lease.mac %]</td> + <td align='center'>[% lease.ip %]</td> + <td align='center'>[% lease.hostname %] </td> + <td align='center'>[% lease.remark %] </td> + <td align='center'>[% lease.nextaddr %] </td> + <td align='center'>[% lease.filename %] </td> + <td align='center'>[% lease.rootpath %] </td> + + <td align='center'> + <form method='post' name='frm_fixed_ted_[% loop.index %]' action='[% page.url %]'> + <input type='hidden' name='ACTION' value='[% 'toggle enable disable' | loc %]_fixed' /> + <input type='image' name='[% 'toggle enable disable' | loc %]' src='/images/[% gif %]' alt='[% gdesc %]' title='[% gdesc %]' /> + <input type='hidden' name='KEY_FIXED' value='[% loop.index %]' /> + </form> + </td> + + <td align='center'> + <form method='post' name='frm_fixed_e_[% loop.indx %]' action='[% page.url %]'> + <input type='hidden' name='ACTION' value='[% 'edit' | loc %]_fixed' /> + <input type='image' name='[% 'edit' | loc %]' src='/images/edit.gif' alt='[% 'edit' | loc %]' title='[% 'edit' | loc %]' /> + <input type='hidden' name='KEY_FIXED' value='[% loop.index %]' /> + </form> + </td> + + <td align='center'> + <form method='post' name='frm_fixed_r_[% loop.indx %]' action='[% page.url %]'> + <input type='hidden' name='ACTION' value='[% 'remove' | loc %]_fixed' /> + <input type='image' name='[% 'remove' | loc %]' src='/images/delete.gif' alt='[% 'remove' | loc %]' title='[% 'remove' | loc %]' /> + <input type='hidden' name='KEY_FIXED' value='[% loop.index %]' /> + </form> + </td> +</tr> +[% END %] +</table> + +[% IF fixedleases.size > 0 && disable_fixed %] +<table> +<tr> + <td class='boldbase'> <b>[% 'legend' | loc %]: </b></td> + <td><img src='/images/on.gif' alt='[% 'click to disable' | loc %]' /></td> + <td class='base'>[% 'click to disable' | loc %]</td> + <td> </td> + <td><img src='/images/off.gif' alt='[% 'click to enable' | loc %]' /></td> + <td class='base'>[% 'click to enable' | loc %]</td> + <td> </td> + <td><img src='/images/edit.gif' alt='[% 'edit' | loc %]' /></td> + <td class='base'>[% 'edit' | loc %]</td> + <td> </td> + <td><img src='/images/delete.gif' alt='[% 'remove' | loc %]' /></td> + <td class='base'>[% 'remove' | loc %]</td> +</tr> +</table> +[% END %] +[% INCLUDE "$page.theme/closebox.tpl" %] + +[% IF leases.size > 0 %] + [% caption = 'current dynamic leases' FILTER loc %] + [% INCLUDE "$page.theme/openbox.tpl" + width = '100%' + align = 'left' + caption = caption _ ':' + boxframe = boxframe %] + + <table width='100%'> + <tr> + <td width='25%' align='center'><a href='[% page.url %]?ETHER[% 'Rev' IF dhcpsettings.SORT_LEASELIST == 'ETHER' %]'><b>[% 'mac address' | loc %]</b></a> + [% mytheme.sortdn IF dhcpsettings.SORT_LEASELIST == 'ETHERRev' %] + [% mytheme.sortup IF dhcpsettings.SORT_LEASELIST == 'ETHER' %]</td> + <td width='25%' align='center'><a href='[% page.url %]?IPADDR[% 'Rev' IF dhcpsettings.SORT_LEASELIST == 'IPADDR' %]'><b>[% 'ip address' | loc %]</b></a> + [% mytheme.sortdn IF dhcpsettings.SORT_LEASELIST == 'IPADDRRev' %] + [% mytheme.sortup IF dhcpsettings.SORT_LEASELIST == 'IPADDR' %]</td> + <td width='20%' align='center'><a href='[% page.url %]?HOSTNAME[% 'Rev' IF dhcpsettings.SORT_LEASELIST == 'HOSTNAME' %]'><b>[% 'hostname' | loc %]</b></a> + [% mytheme.sortdn IF dhcpsettings.SORT_LEASELIST == 'HOSTNAMERev' %] + [% mytheme.sortup IF dhcpsettings.SORT_LEASELIST == 'HOSTNAME' %]</td> + <td width='30%' align='center'><a href='[% page.url %]?ENDTIME[% 'Rev' IF dhcpsettings.SORT_LEASELIST == 'ENDTIME' %]'><b>[% 'lease expires' | loc %] (local time d/m/y)</b></a> + [% mytheme.sortdn IF dhcpsettings.SORT_LEASELIST == 'ENDTIMERev' %] + [% mytheme.sortup IF dhcpsettings.SORT_LEASELIST == 'ENDTIME' %]</td> + </tr> + [% FOREACH lease IN leases %] + <tr class='table[% (loop.index % 2) + 1 %]colour'> + <td align='center'>[% lease.ETHER %]</td> + <td align='center'>[% lease.IPADDR %]</td> + <td align='center'> [% lease.HOSTNAME %]</td> + <td align='center'> + [% IF lease.ENDTIME == 'never' %] + [% 'no time limit' | loc %] + [% ELSE %] + [% USE date %] + [% now = date.format(date.now, '%s') %] + [% IF now > lease.ENDTIME %] + <strike>[% date.format(lease.ENDTIME, format="%d/%m/%y %H:%M:%S") %]</strike> + [% ELSE %] + [% date.format(lease.ENDTIME, format="%d/%m/%y %H:%M:%S") %] + [% END %] + [% END %] + </td></tr> + [% END %] + </table> + [% INCLUDE "$page.theme/closebox.tpl" %] +[% END %] + +[% INCLUDE "$page.theme/closebigbox.tpl" %] +[% INCLUDE "$page.theme/footer.tpl" %] Added: ipcop/branches/template-branch/html/html/pages/netstatus.tpl =================================================================== --- ipcop/branches/template-branch/html/html/pages/netstatus.tpl (rev 0) +++ ipcop/branches/template-branch/html/html/pages/netstatus.tpl 2009-06-17 15:18:40 UTC (rev 3077) @@ -0,0 +1,145 @@ +[% location = 'network' | loc %] +[% sublocation = 'ssnetwork status' | loc %] +[% title = 'network status information' | loc %] + +[% PROCESS "$page.theme/vars.tpl" %] +[% INCLUDE "$page.theme/header.tpl" %] +[% INCLUDE "$page.theme/openbigbox.tpl" + align = 'left' %] + +[% INCLUDE "$page.theme/errorbox.tpl" %] +[% INCLUDE "$page.theme/warningbox.tpl" %] + +<table width='100%' cellspacing='0' cellpadding='5'border='0'> +<tr><td style='background-color: #FFFFFF;' align='left'> + <a href='#interfaces'>[% 'interfaces' | loc %]:</a> | + [% IF netsettings.RED_COUNT >= 1 AND netsettings.RED_1_TYPE == 'DHCP' %] + <a href='#reddhcp'>RED [% 'dhcp configuration' | loc %]:</a> | + [% END %] + [% IF dhcpserver > 0 %] + <a href='#leases'>[% 'current dynamic leases' | loc %]:</a> | + [% END %] + [% IF pppsettings.TYPE.match ('^(bewanadsl|alcatelusbk|conexantpciadsl|eagleusbadsl|wanpipe)$') %] + <a href='#adsl'>[% 'adsl settings' | loc %]</a> | + [% END %] + <a href='#routing'>[% 'routing table entries' | loc %]:</a> | + <a href='#arp'>[% 'arp table entries' | loc %]:</a> + </td> +</tr></table> + +<a name='interfaces'/> +[% caption = 'interfaces'|loc %] +[% INCLUDE "$page.theme/openbox.tpl" + width = '100%' + align = 'left' + caption = caption _ ":" %] +<pre>[% interfaces %]</pre> +[% INCLUDE "$page.theme/closebox.tpl" %] + +[% IF netsettings.RED_COUNT >= 1 AND netsettings.RED_1_TYPE == 'DHCP' %] + <a name='reddhcp'/> + [% caption = 'dhcp configuration'|loc %] + [% INCLUDE "$page.theme/openbox.tpl" + width = '100%' + align = 'left' + caption = "RED " _ caption _ ":" %] + + [% IF dhcpinfo.size > 0 %] + <table width='100%'> + [% IF dhcpinfo.DHCLIENT_HOSTNAME %] + <tr><td width='30%'>[% 'hostname' | loc %]:</td> + <td>[% dhcpinfo.DHCLIENT_HOSTNAME %].[% dhcpinfo.DHCLIENT_DOMAIN %]</td></tr> + [% ELSE %] + <tr><td width='30%'>[% 'domain' | loc %]:</td><td>[% dhcpinfo.DHCLIENT_DOMAIN %]</td></tr>\n"; + [% END %] + <tr><td>[% 'gateway' | loc %]:</td><td>[% dhcpinfo.DHCLIENT_GATEWAY %]</td></tr> + <tr><td>[% 'primary dns' | loc %]:</td><td>[% dhcpinfo.DHCLIENT_DNS1 %]</td></tr> + <tr><td>[% 'secondary dns' | loc %]:</td><td>[% dhcpinfo.DHCLIENT_DNS2 %]</td></tr> + <tr><td>[% 'dhcp server' | loc %]:</td><td>[% dhcpinfo.DHCLIENT_SIADDR %]</td></tr> + <tr><td>[% 'def lease time' | loc %]:</td><td>[% dhcpinfo.leasetime %]</td></tr> + <tr><td>[% 'lease expires' | loc %]:</td><td>[% dhcpinfo.leaseexpires %]</td></tr> + </table> + [% ELSE %] + [% 'no dhcp lease' | loc %] + [% END %] + [% INCLUDE "$page.theme/closebox.tpl" %] +[% END %] + +[% IF leases.size > 0 %] + <a name='leases'/> + [% caption = 'current dynamic leases' FILTER loc %] + [% INCLUDE "$page.theme/openbox.tpl" + width = '100%' + align = 'left' + caption = caption _ ':' + boxframe = boxframe %] + + <table width='100%'> + <tr> + <td width='25%' align='center'><a href='[% page.url %]?ETHER[% 'Rev' IF dhcpsettings.SORT_LEASELIST == 'ETHER' %]'><b>[% 'mac address' | loc %]</b></a> + [% mytheme.sortdn IF dhcpsettings.SORT_LEASELIST == 'ETHERRev' %] + [% mytheme.sortup IF dhcpsettings.SORT_LEASELIST == 'ETHER' %]</td> + <td width='25%' align='center'><a href='[% page.url %]?IPADDR[% 'Rev' IF dhcpsettings.SORT_LEASELIST == 'IPADDR' %]'><b>[% 'ip address' | loc %]</b></a> + [% mytheme.sortdn IF dhcpsettings.SORT_LEASELIST == 'IPADDRRev' %] + [% mytheme.sortup IF dhcpsettings.SORT_LEASELIST == 'IPADDR' %]</td> + <td width='20%' align='center'><a href='[% page.url %]?HOSTNAME[% 'Rev' IF dhcpsettings.SORT_LEASELIST == 'HOSTNAME' %]'><b>[% 'hostname' | loc %]</b></a> + [% mytheme.sortdn IF dhcpsettings.SORT_LEASELIST == 'HOSTNAMERev' %] + [% mytheme.sortup IF dhcpsettings.SORT_LEASELIST == 'HOSTNAME' %]</td> + <td width='30%' align='center'><a href='[% page.url %]?ENDTIME[% 'Rev' IF dhcpsettings.SORT_LEASELIST == 'ENDTIME' %]'><b>[% 'lease expires' | loc %] (local time d/m/y)</b></a> + [% mytheme.sortdn IF dhcpsettings.SORT_LEASELIST == 'ENDTIMERev' %] + [% mytheme.sortup IF dhcpsettings.SORT_LEASELIST == 'ENDTIME' %]</td> + </tr> + [% FOREACH lease IN leases %] + <tr class='table[% (loop.index % 2) + 1 %]colour'> + <td align='center'>[% lease.ETHER %]</td> + <td align='center'>[% lease.IPADDR %]</td> + <td align='center'> [% lease.HOSTNAME %]</td> + <td align='center'> + [% IF lease.ENDTIME == 'never' %] + [% 'no time limit' | loc %] + [% ELSE %] + [% USE date %] + [% now = date.format(date.now, '%s') %] + [% IF now > lease.ENDTIME %] + <strike>[% date.format(lease.ENDTIME, format="%d/%m/%y %H:%M:%S") %]</strike> + [% ELSE %] + [% date.format(lease.ENDTIME, format="%d/%m/%y %H:%M:%S") %] + [% END %] + [% END %] + </td></tr> + [% END %] + </table> + [% INCLUDE "$page.theme/closebox.tpl" %] +[% END %] + +[% IF pppsettings.TYPE.match ('^(bewanadsl|alcatelusbk|conexantpciadsl|eagleusbadsl|wanpipe)$') %] + <a name='adsl'/> + [% caption = 'adsl settings'|loc %] + [% INCLUDE "$page.theme/openbox.tpl" + width = '100%' + align = 'left' + caption = caption _ ":" %] + <pre>[% adsl %]</pre> + [% INCLUDE "$page.theme/closebox.tpl" %] +[% END %] + +<a name='routing'/> +[% caption = 'routing table entries'|loc %] +[% INCLUDE "$page.theme/openbox.tpl" + width = '100%' + align = 'left' + caption = caption _ ":" %] +<pre>[% route | color_devices %]</pre> +[% INCLUDE "$page.theme/closebox.tpl" %] + +<a name='arp'/> +[% caption = 'arp table entries'|loc %] +[% INCLUDE "$page.theme/openbox.tpl" + width = '100%' + align = 'left' + caption = caption _ ":" %] +<pre>[% arp | color_devices %]</pre> +[% INCLUDE "$page.theme/closebox.tpl" %] + +[% INCLUDE "$page.theme/closebigbox.tpl" %] +[% INCLUDE "$page.theme/footer.tpl" %] Modified: ipcop/branches/template-branch/src/libs/general-functions.pl =================================================================== --- ipcop/branches/template-branch/src/libs/general-functions.pl 2009-06-17 15:14:05 UTC (rev 3076) +++ ipcop/branches/template-branch/src/libs/general-functions.pl 2009-06-17 15:18:40 UTC (rev 3077) @@ -1075,6 +1075,69 @@ &Header::closebox(); } +sub GetActualLeases +{ + my $list = $_[0]; + our %dhcpsettings = (); + + sub leasesort + { + my $qs = ''; + if (rindex($dhcpsettings{'SORT_LEASELIST'}, 'Rev') != -1) { + $qs = substr($dhcpsettings{'SORT_LEASELIST'}, 0, length($dhcpsettings{'SORT_LEASELIST'}) - 3); + if ($qs eq 'IPADDR') { + my @a = split(/\./, $a->{$qs}); + my @b = split(/\./, $b->{$qs}); + ($b[0] <=> $a[0]) + || ($b[1] <=> $a[1]) + || ($b[2] <=> $a[2]) + || ($b[3] <=> $a[3]); + } + else { + $b->{$qs} cmp $a->{$qs}; + } + } + else #not reverse + { + $qs = $dhcpsettings{'SORT_LEASELIST'}; + if ($qs eq 'IPADDR') { + my @a = split(/\./, $a->{$qs}); + my @b = split(/\./, $b->{$qs}); + ($a[0] <=> $b[0]) + || ($a[1] <=> $b[1]) + || ($a[2] <=> $b[2]) + || ($a[3] <=> $b[3]); + } + else { + $a->{$qs} cmp $b->{$qs}; + } + } + } + + my @leases = (); + my ($ip, $endtime, $ether, $hostname, @record, $record); + open(LEASES, "/var/run/dnsmasq/dnsmasq.leases"); + while (my $line = <LEASES>) { + next if ($line =~ /^\s*#/); + chomp($line); + my @temp = split(' ', $line); + + my $hostname = &Header::cleanhtml($temp[3], "y"); + my %lease = ( + 'IPADDR' => $temp[2], + 'ENDTIME' => $temp[0], + 'ETHER' => $temp[1], + 'HOSTNAME' => $hostname); + push (@leases, \%lease); + } + close(LEASES); + + #Get sort method + $dhcpsettings{'SORT_LEASELIST'} = 'IPADDR'; #default + &General::readhash("${General::swroot}/dhcp/settings", \%dhcpsettings); #or maybe saved ! + @{$list} = sort leasesort @leases; +} + sub speedtouchversion { my $speedtouch; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. ------------------------------------------------------------------------------ Crystal Reports - New Free Runtime and 30 Day Trial Check out the new simplified licensing option that enables unlimited royalty-free distribution of the report engine for externally facing server and web deployment. http://p.sf.net/sfu/businessobjects _______________________________________________ Ipcop-svn mailing list Ipcop-svn@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/ipcop-svn