#
# SMArT
#
# Handle /settings/ requests
#
# Copyright 2001 Wilmer van der Gaast (lintux@lintux.cx)
#
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#
#
sub html_escape( $ )
{
my $s = $_[0];
$s = '' unless defined $s;
$s =~ s/&/&/g;
$s =~ s/</g;
$s =~ s/>/>/g;
$s =~ s/"/"/g;
return $s;
}
sub network_interface_options( $ )
{
my $current = $_[0];
my @interfaces = ();
my %seen = ();
my $html = '';
$current = '' unless defined $current;
if( opendir( my $dh, '/sys/class/net' ) )
{
foreach my $ifname ( sort readdir( $dh ) )
{
next if $ifname =~ /^\./;
next if $ifname =~ /[^-_\.A-Za-z0-9]/;
next if $seen{$ifname};
push( @interfaces, $ifname );
$seen{$ifname} = 1;
}
closedir( $dh );
}
# Keep special/manual values usable even if they are not real kernel interfaces.
foreach my $ifname ( '*', 'auto', $current )
{
next if !defined( $ifname ) || $ifname eq '';
next if $seen{$ifname};
push( @interfaces, $ifname );
$seen{$ifname} = 1;
}
foreach my $ifname ( @interfaces )
{
my $selected = ( $ifname eq $current ) ? ' SELECTED' : '';
my $label = $ifname;
$label = '* (all interfaces)' if $ifname eq '*';
$label = 'auto' if $ifname eq 'auto';
$html .= '\t\t\t\t\n';
}
return $html;
}
sub handle_request()
{
if( $c[1] eq 'general' )
{
$server_name = getconfigline( 2 );
$internal_net = getconfigline( 3 );
( $burst_read, $burst_write ) = split( ' ', getconfigline( 30 ) );
$timing_down = getconfigline( 210 );
$timing_warn = getconfigline( 211 );
eval( '$test_' . getconfigline( 16 ) . ' = " CHECKED";' );
eval( '$version_' . ( split( ' ', getconfigline( 6 ) ) )[0] . ' = " CHECKED";' );
if( ( split( ' ', getconfigline( 6 ) ) )[1] == 1 )
{
$burst_enabled_0 = ' CHECKED';
}
else
{
$burst_enabled_0 = '';
}
print <SMArT Settings