# 
# 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/&/&amp;/g;
	$s =~ s/</&lt;/g;
	$s =~ s/>/&gt;/g;
	$s =~ s/"/&quot;/g;
	return $s;
}


sub settings_nav_bar()
{
	return <<'EOF_NAV';
<div class="settings-nav" style="position:sticky;top:0;z-index:20;margin:-14px -14px 14px -14px;padding:10px 14px;background:#f6f2ea;border-bottom:1px solid #ddcfba;box-shadow:0 4px 12px rgba(80,55,30,0.06);">
  <a class="settings-nav-back" style="display:inline-block;margin-right:10px;padding:7px 12px;border-radius:9px;background:#6d5d53;color:#fff;text-decoration:none;font-weight:bold;" href="javascript:history.back()">Back</a>
  <a class="settings-nav-main" style="display:inline-block;padding:7px 12px;border-radius:9px;background:#a32020;color:#fff;text-decoration:none;font-weight:bold;" href="/" target="_top">Main menu</a>
</div>
EOF_NAV
}

sub delete_confirm_attr( $ )
{
	my $what = html_escape( $_[0] );
	return ' onclick="return confirm(\'Delete ' . $what . '?\')"';
}

$settings_nav_bar = settings_nav_bar();

sub kernel_network_interfaces()
{
	my %interfaces = ();

	if( opendir( my $dh, '/sys/class/net' ) )
	{
		foreach my $ifname ( readdir( $dh ) )
		{
			next if $ifname =~ /^\./;
			next if $ifname =~ /[^-_\.A-Za-z0-9]/;
			$interfaces{$ifname} = 1;
		}
		closedir( $dh );
	}

	return %interfaces;
}

sub ipx_enabled_interfaces()
{
	my %ipx_interfaces = ();

	# Modern Linux IPX procfs format:
	# Network    Node_Address   Primary  Device          Frame_Type
	# AC100B98   000000000001   Yes      Internal        None
	# 00000022   508140F6AC45   No       enp46s0u1u3u3   802.2
	if( open( my $fh, '<', '/proc/net/ipx/interface' ) )
	{
		while( my $line = <$fh> )
		{
			chomp( $line );
			$line =~ s/^\s+//;
			$line =~ s/\s+$//;

			next if $line eq '';
			next if $line =~ /^Network\s+Node_Address\s+Primary\s+Device\s+Frame_Type/i;

			my @fields = split( /\s+/, $line );

			# Device is the fourth column.  Do not scan all tokens, otherwise
			# Network/Node/Frame_Type values can accidentally be treated as names.
			next if scalar( @fields ) < 5;

			my $dev = $fields[3];
			next if ! defined( $dev );
			next if $dev eq '';
			next if lc( $dev ) eq 'internal';
			next if $dev =~ /[^-_\.A-Za-z0-9]/;

			# Only show real Linux network interfaces.
			next if ! -e '/sys/class/net/' . $dev;

			$ipx_interfaces{$dev} = 1;
		}

		close( $fh );
	}

	# Fallback for older distributions/tools, if present.  This parser is kept
	# deliberately conservative and still verifies /sys/class/net/<device>.
	if( open( my $fh, '<', '/proc/net/ipx_interfaces' ) )
	{
		while( my $line = <$fh> )
		{
			chomp( $line );
			$line =~ s/^\s+//;
			$line =~ s/\s+$//;

			next if $line eq '';
			next if $line =~ /^(Network|Net|Address|Node|Interface|Device)\b/i;

			foreach my $dev ( split( /\s+/, $line ) )
			{
				next if ! defined( $dev );
				next if $dev eq '';
				next if lc( $dev ) eq 'internal';
				next if $dev =~ /[^-_\.A-Za-z0-9]/;
				next if ! -e '/sys/class/net/' . $dev;

				$ipx_interfaces{$dev} = 1;
			}
		}

		close( $fh );
	}

	return sort keys %ipx_interfaces;
}

sub network_interface_options( $ )
{
	my $current = $_[0];
	my @interfaces = ();
	my %seen = ();
	my $html = '';

	$current = '' unless defined $current;

	# Only show interfaces where IPX is currently active.  The current value is
	# still preserved below, so an existing config entry is not lost if the
	# interface is temporarily down or IPX is not loaded at display time.
	foreach my $ifname ( ipx_enabled_interfaces() )
	{
		next if $seen{$ifname};
		push( @interfaces, $ifname );
		$seen{$ifname} = 1;
	}

	# 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 IPX interfaces)' if $ifname eq '*';
		$label = 'auto' if $ifname eq 'auto';
		$html .= '\t\t\t\t<OPTION VALUE="' . html_escape( $ifname ) . '"' . $selected . '>' . html_escape( $label ) . '</OPTION>\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 <<EOF;
HTTP/1.0 200 OK
Content-Type: text/html
$server_id

<HTML>
<HEAD>
<TITLE>SMArT Settings</TITLE>
<link rel="icon" href="/static/favicon.ico" type="image/x-icon">
<link rel="icon" type="image/png" sizes="16x16" href="/static/favicon-16x16.png">
<link rel="icon" type="image/png" sizes="32x32" href="/static/favicon-32x32.png">
<link rel="apple-touch-icon" href="/static/apple-touch-icon.png">
<link rel="icon" type="image/png" sizes="192x192" href="/static/android-chrome-192x192.png">
<link rel="icon" type="image/png" sizes="512x512" href="/static/android-chrome-512x512.png">
<style>
BODY { background:#f6f2ea; color:#2e261d; font-family: Arial, Helvetica, sans-serif; margin:0; padding:14px; }
FORM { margin:0; }
TABLE { border-collapse:separate; border-spacing:0; width:100%; background:#fbf7f1; border:1px solid #ddcfba; border-radius:18px; overflow:hidden; box-shadow:0 6px 18px rgba(80,55,30,0.08); }
TD { padding:10px 12px; }
TR + TR TD { border-top:1px solid #eadfce; }
TR:first-child TD:first-child { border-top-left-radius:18px; }
TR:first-child TD:last-child { border-top-right-radius:18px; }
TR:last-child TD:first-child { border-bottom-left-radius:18px; }
TR:last-child TD:last-child { border-bottom-right-radius:18px; }
INPUT, SELECT, TEXTAREA { font-family: Arial, Helvetica, sans-serif; font-size:14px; }
INPUT[type=TEXT], INPUT[type=PASSWORD], SELECT, TEXTAREA {
  border:1px solid #cdbb9f; border-radius:10px; padding:6px 10px; background:#fffdf9; color:#2e261d;
}
INPUT[type=SUBMIT], INPUT[type=RESET], INPUT[type=BUTTON] {
  border:1px solid #a33d2f; border-radius:10px; padding:8px 14px; background:#b84434; color:#fff; font-weight:bold;
}
A { color:#9f2f26; }
TT { color:#5b4b38; }
</style>
</HEAD>
<BODY BGCOLOR="#f6f2ea">
$settings_nav_bar

<FORM ACTION="/apply/general" METHOD=GET>
<TABLE BORDER=0 CELLSPACING=0 WIDTH=100%>
	<TR BGCOLOR="#d7c0a0">
		<TD>
			<B><FONT SIZE=+2>General settings</FONT></B>
		</TD>
		<TD ALIGN=RIGHT>
			<IMG SRC="/static/smart_icon.jpg"><BR>
		</TD>
	</TR>
	<TR BGCOLOR="#fbf7f1">
		<TD>
			<B>Server name:</B>
		</TD>
		<TD ALIGN=RIGHT>
			<INPUT NAME="server_name" TYPE=TEXT SIZE=20 VALUE="$server_name"><BR>
		</TD>
	</TR>
	<TR BGCOLOR="#fbf7f1">
		<TD>
			<B>Internal network:</B>
		</TD>
		<TD ALIGN=RIGHT>
			<INPUT NAME="internal_net" TYPE=TEXT SIZE=20 VALUE="$internal_net"><BR>
		</TD>
	</TR>
	<TR BGCOLOR="#fbf7f1">
		<TD>
			<B>Tests at startup:</B>
		</TD>
		<TD ALIGN=RIGHT>
			None<INPUT NAME="test" TYPE=RADIO VALUE=0$test_0><BR>
			Some<INPUT NAME="test" TYPE=RADIO VALUE=1$test_1><BR>
			Check/compress bindery<INPUT NAME="test" TYPE=RADIO VALUE=2$test_2><BR>
		</TD>
	</TR>
	<TR BGCOLOR="#fbf7f1">
		<TD>
			<B>Server version:</B>
		</TD>
		<TD ALIGN=RIGHT>
			2.15<INPUT NAME="version" TYPE=RADIO VALUE=0$version_0><BR>
			3.11<INPUT NAME="version" TYPE=RADIO VALUE=1$version_1><BR>
			3.12<INPUT NAME="version" TYPE=RADIO VALUE=2$version_2><BR>
		</TD>
	</TR>
	<TR BGCOLOR="#ece0cf">
		<TD COLSPAN=2>
			<B><FONT>Burst mode</FONT></B><BR>
		</TD>
	</TR>
	<TR BGCOLOR="#fbf7f1">
		<TD>
			<B>Burst mode:</B>
		</TD>
		<TD ALIGN=RIGHT>
			Enabled<INPUT NAME="burst_enabled" TYPE=CHECKBOX$burst_enabled_0><BR>
		</TD>
	</TR>
	<TR BGCOLOR="#fbf7f1">
		<TD>
			<B>MAX_BURST_READ_BUF:</B>
		</TD>
		<TD ALIGN=RIGHT>
			<INPUT NAME="burst_read" TYPE=TEXT SIZE=20 VALUE="$burst_read"><BR>
		</TD>
	</TR>
	<TR BGCOLOR="#fbf7f1">
		<TD>
			<B>MAX_BURST_WRITE_BUF:</B>
		</TD>
		<TD ALIGN=RIGHT>
			<INPUT NAME="burst_write" TYPE=TEXT SIZE=20 VALUE="$burst_write"><BR>
		</TD>
	</TR>
	<TR BGCOLOR="#ece0cf">
		<TD COLSPAN=2>
			<B><FONT>Timing</FONT></B><BR>
		</TD>
	</TR>
	<TR BGCOLOR="#fbf7f1">
		<TD>
			<B>Wait for <I>x</I> seconds before shutdown:</B>
		</TD>
		<TD ALIGN=RIGHT>
			<INPUT NAME="timing_down" TYPE=TEXT SIZE=20 VALUE="$timing_down"><BR>
		</TD>
	</TR>
	<TR BGCOLOR="#fbf7f1">
		<TD>
			<B>Warn users every <I>x</I> seconds:</B>
		</TD>
		<TD ALIGN=RIGHT>
			<INPUT NAME="timing_warn" TYPE=TEXT SIZE=20 VALUE="$timing_warn"><BR>
		</TD>
	</TR>
	<TR BGCOLOR="#d7c0a0">
		<TD>
			<INPUT TYPE=SUBMIT VALUE="OK">
		</TD>
		<TD ALIGN=RIGHT>
			<INPUT TYPE=RESET VALUE="Undo changes"><BR>
		</TD>
	</TR>
</TABLE>
</FORM>

</BODY>
</HTML>
EOF
	}
	elsif( $c[1] eq 'dirs' )
	{
		$path_cache = getconfigline( 40 );
		$share_lock = getconfigline( 41 );
		$spool = getconfigline( 42 );
		$bindery = getconfigline( 45 );
		$attribute = getconfigline( 46 );
		$trustee = getconfigline( 47 );
		
	print <<EOF;
HTTP/1.0 200 OK
Content-Type: text/html
$server_id

<HTML>
<HEAD>
<TITLE>SMArT Settings</TITLE>
<link rel="icon" href="/static/favicon.ico" type="image/x-icon">
<link rel="icon" type="image/png" sizes="16x16" href="/static/favicon-16x16.png">
<link rel="icon" type="image/png" sizes="32x32" href="/static/favicon-32x32.png">
<link rel="apple-touch-icon" href="/static/apple-touch-icon.png">
<link rel="icon" type="image/png" sizes="192x192" href="/static/android-chrome-192x192.png">
<link rel="icon" type="image/png" sizes="512x512" href="/static/android-chrome-512x512.png">
<style>
BODY { background:#f6f2ea; color:#2e261d; font-family: Arial, Helvetica, sans-serif; margin:0; padding:14px; }
FORM { margin:0; }
TABLE { border-collapse:separate; border-spacing:0; width:100%; background:#fbf7f1; border:1px solid #ddcfba; border-radius:18px; overflow:hidden; box-shadow:0 6px 18px rgba(80,55,30,0.08); }
TD { padding:10px 12px; }
TR + TR TD { border-top:1px solid #eadfce; }
TR:first-child TD:first-child { border-top-left-radius:18px; }
TR:first-child TD:last-child { border-top-right-radius:18px; }
TR:last-child TD:first-child { border-bottom-left-radius:18px; }
TR:last-child TD:last-child { border-bottom-right-radius:18px; }
INPUT, SELECT, TEXTAREA { font-family: Arial, Helvetica, sans-serif; font-size:14px; }
INPUT[type=TEXT], INPUT[type=PASSWORD], SELECT, TEXTAREA {
  border:1px solid #cdbb9f; border-radius:10px; padding:6px 10px; background:#fffdf9; color:#2e261d;
}
INPUT[type=SUBMIT], INPUT[type=RESET], INPUT[type=BUTTON] {
  border:1px solid #a33d2f; border-radius:10px; padding:8px 14px; background:#b84434; color:#fff; font-weight:bold;
}
A { color:#9f2f26; }
TT { color:#5b4b38; }
</style>
</HEAD>
<BODY BGCOLOR="#f6f2ea">
$settings_nav_bar

<FORM ACTION="/apply/dirs" METHOD=GET>
<TABLE BORDER=0 CELLSPACING=0 WIDTH=100%>
	<TR BGCOLOR="#d7c0a0">
		<TD>
			<B><FONT SIZE=+2>Directories</FONT></B>
		</TD>
		<TD ALIGN=RIGHT>
			<IMG SRC="/static/smart_icon.jpg"><BR>
		</TD>
	</TR>
	<TR BGCOLOR="#fbf7f1">
		<TD>
			<B>Path cache directory:</B>
		</TD>
		<TD ALIGN=RIGHT>
			<INPUT NAME="path_cache" TYPE=TEXT SIZE=32 VALUE="$path_cache"><BR>
		</TD>
	</TR>
	<TR BGCOLOR="#fbf7f1">
		<TD>
			<B>Share and lock files:</B>
		</TD>
		<TD ALIGN=RIGHT>
			<INPUT NAME="share_lock" TYPE=TEXT SIZE=32 VALUE="$share_lock"><BR>
		</TD>
	</TR>
	<TR BGCOLOR="#fbf7f1">
		<TD>
			<B>Spool directory:</B>
		</TD>
		<TD ALIGN=RIGHT>
			<INPUT NAME="spool" TYPE=TEXT SIZE=32 VALUE="$spool"><BR>
		</TD>
	</TR>
	<TR BGCOLOR="#fbf7f1">
		<TD>
			<B>Bindery files:</B>
		</TD>
		<TD ALIGN=RIGHT>
			<INPUT NAME="bindery" TYPE=TEXT SIZE=32 VALUE="$bindery"><BR>
		</TD>
	</TR>
	<TR BGCOLOR="#fbf7f1">
		<TD>
			<B>Attribute handling files:</B>
		</TD>
		<TD ALIGN=RIGHT>
			<INPUT NAME="attribute" TYPE=TEXT SIZE=32 VALUE="$attribute"><BR>
		</TD>
	</TR>
	<TR BGCOLOR="#fbf7f1">
		<TD>
			<B>Trustee handling files:</B>
		</TD>
		<TD ALIGN=RIGHT>
			<INPUT NAME="trustee" TYPE=TEXT SIZE=32 VALUE="$trustee"><BR>
		</TD>
	</TR>
	<TR BGCOLOR="#d7c0a0">
		<TD>
			<INPUT TYPE=SUBMIT VALUE="OK">
		</TD>
		<TD ALIGN=RIGHT>
			<INPUT TYPE=RESET VALUE="Undo changes"><BR>
		</TD>
	</TR>
</TABLE>
</FORM>

</BODY>
</HTML>
EOF
	}
	elsif( $c[1] eq 'configh' )
	{
		$net_serial = getconfigline( 70 );
		$net_app = getconfigline( 71 );
		if( getconfigline( 68 ) eq '1' )
		{
			$mmap_0 = ' CHECKED';
		}
		else
		{
			$mmap_0 = '';
		}
		eval( '$sap_' . getconfigline( 69 ) . ' = " CHECKED";' );
		$max_conn = getconfigline( 60 );
		$max_vol = getconfigline( 61 );
		$max_dirbase = getconfigline( 63 );
		
		
		print <<EOF;
HTTP/1.0 200 OK
Content-Type: text/html
$server_id

<HTML>
<HEAD>
<TITLE>SMArT Settings</TITLE>
<link rel="icon" href="/static/favicon.ico" type="image/x-icon">
<link rel="icon" type="image/png" sizes="16x16" href="/static/favicon-16x16.png">
<link rel="icon" type="image/png" sizes="32x32" href="/static/favicon-32x32.png">
<link rel="apple-touch-icon" href="/static/apple-touch-icon.png">
<link rel="icon" type="image/png" sizes="192x192" href="/static/android-chrome-192x192.png">
<link rel="icon" type="image/png" sizes="512x512" href="/static/android-chrome-512x512.png">
<style>
BODY { background:#f6f2ea; color:#2e261d; font-family: Arial, Helvetica, sans-serif; margin:0; padding:14px; }
FORM { margin:0; }
TABLE { border-collapse:separate; border-spacing:0; width:100%; background:#fbf7f1; border:1px solid #ddcfba; border-radius:18px; overflow:hidden; box-shadow:0 6px 18px rgba(80,55,30,0.08); }
TD { padding:10px 12px; }
TR + TR TD { border-top:1px solid #eadfce; }
TR:first-child TD:first-child { border-top-left-radius:18px; }
TR:first-child TD:last-child { border-top-right-radius:18px; }
TR:last-child TD:first-child { border-bottom-left-radius:18px; }
TR:last-child TD:last-child { border-bottom-right-radius:18px; }
INPUT, SELECT, TEXTAREA { font-family: Arial, Helvetica, sans-serif; font-size:14px; }
INPUT[type=TEXT], INPUT[type=PASSWORD], SELECT, TEXTAREA {
  border:1px solid #cdbb9f; border-radius:10px; padding:6px 10px; background:#fffdf9; color:#2e261d;
}
INPUT[type=SUBMIT], INPUT[type=RESET], INPUT[type=BUTTON] {
  border:1px solid #a33d2f; border-radius:10px; padding:8px 14px; background:#b84434; color:#fff; font-weight:bold;
}
A { color:#9f2f26; }
TT { color:#5b4b38; }
</style>
</HEAD>
<BODY BGCOLOR="#f6f2ea">
$settings_nav_bar

<FORM ACTION="/apply/configh" METHOD=GET>
<TABLE BORDER=0 CELLSPACING=0 WIDTH=100%>
	<TR BGCOLOR="#d7c0a0">
		<TD>
			<B><FONT SIZE=+2>Precompiled settings</FONT></B>
		</TD>
		<TD ALIGN=RIGHT>
			<IMG SRC="/static/smart_icon.jpg"><BR>
		</TD>
	</TR>
	<TR BGCOLOR="#fbf7f1">
		<TD>
			<B>Network serial number:</B>
		</TD>
		<TD ALIGN=RIGHT>
			<INPUT NAME="net_serial" TYPE=TEXT SIZE=20 VALUE="$net_serial"><BR>
		</TD>
	</TR>
	<TR BGCOLOR="#fbf7f1">
		<TD>
			<B>Network application number:</B>
		</TD>
		<TD ALIGN=RIGHT>
			<INPUT NAME="net_app" TYPE=TEXT SIZE=20 VALUE="$net_app"><BR>
		</TD>
	</TR>
	<TR BGCOLOR="#fbf7f1">
		<TD>
			<B><TT>mmap()</TT> calls:</B>
		</TD>
		<TD ALIGN=RIGHT>
			Enabled<INPUT NAME="mmap" TYPE=CHECKBOX$mmap_0><BR>
		</TD>
	</TR>
	<TR BGCOLOR="#fbf7f1">
		<TD>
			<B>Handle SAP-types:</B>
		</TD>
		<TD ALIGN=RIGHT>
			Only type 4<INPUT NAME="sap" TYPE=RADIO VALUE=0$sap_0><BR>
			All<INPUT NAME="sap" TYPE=RADIO VALUE=1$sap_1><BR>
		</TD>
	</TR>
	<TR BGCOLOR="#ece0cf">
		<TD COLSPAN=2>
			<B><FONT>Limits</FONT></B><BR>
		</TD>
	</TR>
	<TR BGCOLOR="#fbf7f1">
		<TD>
			<B>Maximum connection count:</B>
		</TD>
		<TD ALIGN=RIGHT>
			<INPUT NAME="max_conn" TYPE=TEXT SIZE=20 VALUE="$max_conn"><BR>
		</TD>
	</TR>
	<TR BGCOLOR="#fbf7f1">
		<TD>
			<B>Maximum volume count:</B>
		</TD>
		<TD ALIGN=RIGHT>
			<INPUT NAME="max_vol" TYPE=TEXT SIZE=20 VALUE="$max_vol"><BR>
		</TD>
	</TR>
	<TR BGCOLOR="#fbf7f1">
		<TD>
			<B>Maximum directory-base entry count:</B>
		</TD>
		<TD ALIGN=RIGHT>
			<INPUT NAME="max_dirbase" TYPE=TEXT SIZE=20 VALUE="$max_dirbase"><BR>
		</TD>
	</TR>
	<TR BGCOLOR="#d7c0a0">
		<TD>
			<INPUT TYPE=SUBMIT VALUE="OK">
		</TD>
		<TD ALIGN=RIGHT>
			<INPUT TYPE=RESET VALUE="Undo changes"><BR>
		</TD>
	</TR>
</TABLE>
</FORM>

</BODY>
</HTML>
EOF
	}
	elsif( $c[1] eq 'security' )
	{
		$creat_dir = ( split( ' ', getconfigline( 9 ) ) )[0];
		$creat_file = ( split( ' ', getconfigline( 9 ) ) )[1];
		eval( '$encrypt_' . getconfigline( 7 ) . ' = " CHECKED";' );
	
		print <<EOF;
HTTP/1.0 200 OK
Content-Type: text/html
$server_id

<HTML>
<HEAD>
<TITLE>SMArT Settings</TITLE>
<link rel="icon" href="/static/favicon.ico" type="image/x-icon">
<link rel="icon" type="image/png" sizes="16x16" href="/static/favicon-16x16.png">
<link rel="icon" type="image/png" sizes="32x32" href="/static/favicon-32x32.png">
<link rel="apple-touch-icon" href="/static/apple-touch-icon.png">
<link rel="icon" type="image/png" sizes="192x192" href="/static/android-chrome-192x192.png">
<link rel="icon" type="image/png" sizes="512x512" href="/static/android-chrome-512x512.png">
<style>
BODY { background:#f6f2ea; color:#2e261d; font-family: Arial, Helvetica, sans-serif; margin:0; padding:14px; }
FORM { margin:0; }
TABLE { border-collapse:separate; border-spacing:0; width:100%; background:#fbf7f1; border:1px solid #ddcfba; border-radius:18px; overflow:hidden; box-shadow:0 6px 18px rgba(80,55,30,0.08); }
TD { padding:10px 12px; }
TR + TR TD { border-top:1px solid #eadfce; }
TR:first-child TD:first-child { border-top-left-radius:18px; }
TR:first-child TD:last-child { border-top-right-radius:18px; }
TR:last-child TD:first-child { border-bottom-left-radius:18px; }
TR:last-child TD:last-child { border-bottom-right-radius:18px; }
INPUT, SELECT, TEXTAREA { font-family: Arial, Helvetica, sans-serif; font-size:14px; }
INPUT[type=TEXT], INPUT[type=PASSWORD], SELECT, TEXTAREA {
  border:1px solid #cdbb9f; border-radius:10px; padding:6px 10px; background:#fffdf9; color:#2e261d;
}
INPUT[type=SUBMIT], INPUT[type=RESET], INPUT[type=BUTTON] {
  border:1px solid #a33d2f; border-radius:10px; padding:8px 14px; background:#b84434; color:#fff; font-weight:bold;
}
A { color:#9f2f26; }
TT { color:#5b4b38; }
</style>
</HEAD>
<BODY BGCOLOR="#f6f2ea">
$settings_nav_bar

<FORM ACTION="/apply/security" METHOD=GET>
<TABLE BORDER=0 CELLSPACING=0 WIDTH=100%>
	<TR BGCOLOR="#d7c0a0">
		<TD>
			<B><FONT SIZE=+2>Security</FONT></B>
		</TD>
		<TD ALIGN=RIGHT>
			<IMG SRC="/static/smart_icon.jpg"><BR>
		</TD>
	</TR>
	<TR BGCOLOR="#fbf7f1">
		<TD>
			<B><TT>creat()</TT> mode for directories:</B>
		</TD>
		<TD ALIGN=RIGHT>
			<INPUT NAME="creat_dir" TYPE=TEXT SIZE=20 VALUE="$creat_dir"><BR>
		</TD>
	</TR>
	<TR BGCOLOR="#fbf7f1">
		<TD>
			<B><TT>creat()</TT> mode for files:</B>
		</TD>
		<TD ALIGN=RIGHT>
			<INPUT NAME="creat_file" TYPE=TEXT SIZE=20 VALUE="$creat_file"><BR>
		</TD>
	</TR>
	<TR BGCOLOR="#fbf7f1">
		<TD>
			<B>Password encryption:</B>
		</TD>
		<TD ALIGN=RIGHT>
			Always encrypt<INPUT NAME="encrypt" TYPE=RADIO VALUE=0$encrypt_0><BR>
			Except when changing password<INPUT NAME="encrypt" TYPE=RADIO VALUE=1$encrypt_1><BR>
			Disallow zero-passwords<INPUT NAME="encrypt" TYPE=RADIO VALUE=7$encrypt_7><BR>
			Allow zero-passwords<INPUT NAME="encrypt" TYPE=RADIO VALUE=8$encrypt_8><BR>
			Disallow encryption<INPUT NAME="encrypt" TYPE=RADIO VALUE=9$encrypt_9><BR>
		</TD>
	</TR>
	<TR BGCOLOR="#d7c0a0">
		<TD>
			<INPUT TYPE=SUBMIT VALUE="OK">
		</TD>
		<TD ALIGN=RIGHT>
			<INPUT TYPE=RESET VALUE="Undo changes"><BR>
		</TD>
	</TR>
</TABLE>
</FORM>

</BODY>
</HTML>
EOF
	}
	elsif( $c[1] eq 'susers' )
	{
		$guest = getconfigline( 11 );
		( $root_name, $root, $root_password ) = split( ' ', getconfigline( 12 ) );
		$guest_user_list = '';
		$root_list = '';
		foreach $u ( unix_userlist() )
		{
			if( $u->{uid} eq $guest )
				{ $guest_user_list .= "\t\t\t" . '<OPTION VALUE="' . $u->{uid} . '" SELECTED>' . $u->{name} . '</OPTION>' . "\n"; }
			else
				{ $guest_user_list .= "\t\t\t" . '<OPTION VALUE="' . $u->{uid} . '">' . $u->{name} . '</OPTION>' . "\n"; }
			if( $u->{name} eq $root )
				{ $root_list .= "\t\t\t" . '<OPTION VALUE="' . $u->{name} . '" SELECTED>' . $u->{name} . '</OPTION>' . "\n"; }
			else
				{ $root_list .= "\t\t\t" . '<OPTION VALUE="' . $u->{name} . '">' . $u->{name} . '</OPTION>' . "\n"; }
		}
		$guest = getconfigline( 10 );
		$guest_group_list = '';
		foreach $u ( unix_grouplist() )
		{
			if( $u->{gid} eq $guest )
				{ $guest_group_list .= "\t\t\t" . '<OPTION VALUE="' . $u->{gid} . '" SELECTED>' . $u->{name} . '</OPTION>' . "\n"; }
			else
				{ $guest_group_list .= "\t\t\t" . '<OPTION VALUE="' . $u->{gid} . '">' . $u->{name} . '</OPTION>' . "\n"; }
		}
		eval( '$map_' . ( split( ' ', getconfigline( 15 ) ) )[0] . ' = " CHECKED";' );
		$map_password = ( split( ' ', getconfigline( 15 ) ) )[1];
		
		print <<EOF;
HTTP/1.0 200 OK
Content-Type: text/html
$server_id

<HTML>
<HEAD>
<TITLE>SMArT Settings</TITLE>
<link rel="icon" href="/static/favicon.ico" type="image/x-icon">
<link rel="icon" type="image/png" sizes="16x16" href="/static/favicon-16x16.png">
<link rel="icon" type="image/png" sizes="32x32" href="/static/favicon-32x32.png">
<link rel="apple-touch-icon" href="/static/apple-touch-icon.png">
<link rel="icon" type="image/png" sizes="192x192" href="/static/android-chrome-192x192.png">
<link rel="icon" type="image/png" sizes="512x512" href="/static/android-chrome-512x512.png">
<style>
BODY { background:#f6f2ea; color:#2e261d; font-family: Arial, Helvetica, sans-serif; margin:0; padding:14px; }
FORM { margin:0; }
TABLE { border-collapse:separate; border-spacing:0; width:100%; background:#fbf7f1; border:1px solid #ddcfba; border-radius:18px; overflow:hidden; box-shadow:0 6px 18px rgba(80,55,30,0.08); }
TD { padding:10px 12px; }
TR + TR TD { border-top:1px solid #eadfce; }
TR:first-child TD:first-child { border-top-left-radius:18px; }
TR:first-child TD:last-child { border-top-right-radius:18px; }
TR:last-child TD:first-child { border-bottom-left-radius:18px; }
TR:last-child TD:last-child { border-bottom-right-radius:18px; }
INPUT, SELECT, TEXTAREA { font-family: Arial, Helvetica, sans-serif; font-size:14px; }
INPUT[type=TEXT], INPUT[type=PASSWORD], SELECT, TEXTAREA {
  border:1px solid #cdbb9f; border-radius:10px; padding:6px 10px; background:#fffdf9; color:#2e261d;
}
INPUT[type=SUBMIT], INPUT[type=RESET], INPUT[type=BUTTON] {
  border:1px solid #a33d2f; border-radius:10px; padding:8px 14px; background:#b84434; color:#fff; font-weight:bold;
}
A { color:#9f2f26; }
TT { color:#5b4b38; }
</style>
</HEAD>
<BODY BGCOLOR="#f6f2ea">
$settings_nav_bar

<FORM ACTION="/apply/susers" METHOD=GET>
<TABLE BORDER=0 CELLSPACING=0 WIDTH=100%>
	<TR BGCOLOR="#d7c0a0">
		<TD>
			<B><FONT SIZE=+2>User configuration</FONT></B>
		</TD>
		<TD ALIGN=RIGHT>
			<IMG SRC="/static/smart_icon.jpg"><BR>
		</TD>
	</TR>
	<TR BGCOLOR="#ece0cf">
		<TD COLSPAN=2>
			<B><FONT>Guest user</FONT></B><BR>
		</TD>
	</TR>
	<TR BGCOLOR="#fbf7f1">
		<TD>
			<B>User:</B>
		</TD>
		<TD ALIGN=RIGHT>
			<SELECT NAME="guest_user" SIZE=5>
$guest_user_list
			</SELECT><BR>
		</TD>
	</TR>
	<TR BGCOLOR="#fbf7f1">
		<TD>
			<B>Group:</B>
		</TD>
		<TD ALIGN=RIGHT>
			<SELECT NAME="guest_group" SIZE=5>
$guest_group_list
			</SELECT><BR>
		</TD>
	</TR>
	<TR BGCOLOR="#ece0cf">
		<TD COLSPAN=2>
			<B><FONT>Supervisor user</FONT></B><BR>
		</TD>
	</TR>
	<TR BGCOLOR="#fbf7f1">
		<TD>
			<B>Username:</B>
		</TD>
		<TD ALIGN=RIGHT>
			<INPUT NAME="root_name" TYPE=TEXT SIZE=20 VALUE="$root_name"><BR>
		</TD>
	</TR>
	<TR BGCOLOR="#fbf7f1">
		<TD>
			<B>Unix user:</B>
		</TD>
		<TD ALIGN=RIGHT>
			<SELECT NAME="root_user" SIZE=5>
$root_list
			</SELECT><BR>
		</TD>
	</TR>
	<TR BGCOLOR="#fbf7f1">
		<TD>
			<B>Password:</B>
		</TD>
		<TD ALIGN=RIGHT>
			<INPUT NAME="root_password" TYPE=PASSWORD SIZE=20 VALUE="$root_password"><BR>
		</TD>
	</TR>
	<TR BGCOLOR="#ece0cf">
		<TD COLSPAN=2>
			<B><FONT>User mapping</FONT></B><BR>
		</TD>
	</TR>
	<TR BGCOLOR="#fbf7f1">
		<TD>
			<B>User mapping:</B>
		</TD>
		<TD ALIGN=RIGHT>
			Disabled<INPUT NAME="map" TYPE=RADIO VALUE=0$map_0><BR>
			Enabled<INPUT NAME="map" TYPE=RADIO VALUE=1$map_1><BR>
			Enabled, overwrite all users<INPUT NAME="map" TYPE=RADIO VALUE=99$map_99><BR>
		</TD>
	</TR>
	<TR BGCOLOR="#fbf7f1">
		<TD>
			<B>Default password:</B>
		</TD>
		<TD ALIGN=RIGHT>
			<INPUT NAME="map_password" TYPE=PASSWORD SIZE=20 VALUE="$map_password"><BR>
		</TD>
	</TR>
	<TR BGCOLOR="#d7c0a0">
		<TD>
			<INPUT TYPE=SUBMIT VALUE="OK">
		</TD>
		<TD ALIGN=RIGHT>
			<INPUT TYPE=RESET VALUE="Undo changes"><BR>
		</TD>
	</TR>
</TABLE>
</FORM>

</BODY>
</HTML>
EOF
	}
	elsif( $c[1] eq 'logging' )
	{
		eval( '$ipx_' . getconfigline( 100 ) . ' = " SELECTED";' );
		eval( '$nwserv_' . getconfigline( 101 ) . ' = " SELECTED";' );
		eval( '$ncpserv_' . getconfigline( 102 ) . ' = " SELECTED";' );
		eval( '$nwconn_' . getconfigline( 103 ) . ' = " SELECTED";' );
		eval( '$nwclient_' . getconfigline( 104 ) . ' = " SELECTED";' );
		eval( '$nwbind_' . getconfigline( 105 ) . ' = " SELECTED";' );
		eval( '$nwrouted_' . getconfigline( 106 ) . ' = " SELECTED";' );
		eval( '$startup_' . getconfigline( 200 ) . ' = " CHECKED";' );
		$general_log = getconfigline( 201 );
		$routing_interval = getconfigline( 300 );
		$routing_log = getconfigline( 301 );

		$x = getconfigline( 202 );
		eval( '$g_creat_' . ( $x & 1 ) . ' = " CHECKED";' );
		eval( '$error_' . ( ( $x - $g_creat ) >> 1 ) . ' = " CHECKED";' );

		$x = getconfigline( 302 );
		eval( '$r_creat_' . ( $x & 1 ) . ' = " CHECKED";' );
		eval( '$r_file_' . ( ( $x - $r_creat ) >> 1 ) . ' = " CHECKED";' );

		print <<EOF;
HTTP/1.0 200 OK
Content-Type: text/html
$server_id

<HTML>
<HEAD>
<TITLE>SMArT Settings</TITLE>
<link rel="icon" href="/static/favicon.ico" type="image/x-icon">
<link rel="icon" type="image/png" sizes="16x16" href="/static/favicon-16x16.png">
<link rel="icon" type="image/png" sizes="32x32" href="/static/favicon-32x32.png">
<link rel="apple-touch-icon" href="/static/apple-touch-icon.png">
<link rel="icon" type="image/png" sizes="192x192" href="/static/android-chrome-192x192.png">
<link rel="icon" type="image/png" sizes="512x512" href="/static/android-chrome-512x512.png">
<style>
BODY { background:#f6f2ea; color:#2e261d; font-family: Arial, Helvetica, sans-serif; margin:0; padding:14px; }
FORM { margin:0; }
TABLE { border-collapse:separate; border-spacing:0; width:100%; background:#fbf7f1; border:1px solid #ddcfba; border-radius:18px; overflow:hidden; box-shadow:0 6px 18px rgba(80,55,30,0.08); }
TD { padding:10px 12px; }
TR + TR TD { border-top:1px solid #eadfce; }
TR:first-child TD:first-child { border-top-left-radius:18px; }
TR:first-child TD:last-child { border-top-right-radius:18px; }
TR:last-child TD:first-child { border-bottom-left-radius:18px; }
TR:last-child TD:last-child { border-bottom-right-radius:18px; }
INPUT, SELECT, TEXTAREA { font-family: Arial, Helvetica, sans-serif; font-size:14px; }
INPUT[type=TEXT], INPUT[type=PASSWORD], SELECT, TEXTAREA {
  border:1px solid #cdbb9f; border-radius:10px; padding:6px 10px; background:#fffdf9; color:#2e261d;
}
INPUT[type=SUBMIT], INPUT[type=RESET], INPUT[type=BUTTON] {
  border:1px solid #a33d2f; border-radius:10px; padding:8px 14px; background:#b84434; color:#fff; font-weight:bold;
}
A { color:#9f2f26; }
TT { color:#5b4b38; }
</style>
</HEAD>
<BODY BGCOLOR="#f6f2ea">
$settings_nav_bar

<FORM ACTION="/apply/logging" METHOD=GET>
<TABLE BORDER=0 CELLSPACING=0 WIDTH=100%>
	<TR BGCOLOR="#d7c0a0">
		<TD>
			<B><FONT SIZE=+2>Logging</FONT></B>
		</TD>
		<TD ALIGN=RIGHT>
			<IMG SRC="/static/smart_icon.jpg"><BR>
		</TD>
	</TR>
	<TR BGCOLOR="#ece0cf">
		<TD COLSPAN=2>
			<B><FONT>Logfiles</FONT></B><BR>
		</TD>
	</TR>
	<TR BGCOLOR="#fbf7f1">
		<TD>
			<B>General logfile:</B>
		</TD>
		<TD ALIGN=RIGHT>
			<INPUT NAME="general_log" TYPE=TEXT SIZE=32 VALUE="$general_log"><BR>
		</TD>
	</TR>
	<TR BGCOLOR="#fbf7f1">
		<TD>
			<B>Routing logfile:</B>
		</TD>
		<TD ALIGN=RIGHT>
			<INPUT NAME="routing_log" TYPE=TEXT SIZE=32 VALUE="$routing_log"><BR>
		</TD>
	</TR>
	<TR BGCOLOR="#ece0cf">
		<TD COLSPAN=2>
			<B><FONT>Parts to log</FONT></B><BR>
		</TD>
	</TR>
	<TR BGCOLOR="#fbf7f1">
		<TD>
			<B>IPX-kernel:</B>
		</TD>
		<TD ALIGN=RIGHT>
			<SELECT NAME="ipx">
				<OPTION VALUE="0"$ipx_0>No debugging</OPTION>
				<OPTION VALUE="1"$ipx_1>Normal debugging</OPTION>
			</SELECT>
		</TD>
	</TR>
	<TR BGCOLOR="#fbf7f1">
		<TD>
			<B>NWSERV:</B>
		</TD>
		<TD ALIGN=RIGHT>
			<SELECT NAME="nwserv">
				<OPTION VALUE="0"$nwserv_0>No debugging</OPTION>
				<OPTION VALUE="1"$nwserv_1>Normal debugging</OPTION>
				<OPTION VALUE="99"$nwserv_99>Maximum debugging</OPTION>
			</SELECT>
		</TD>
	</TR>
	<TR BGCOLOR="#fbf7f1">
		<TD>
			<B>NCPSERV:</B>
		</TD>
		<TD ALIGN=RIGHT>
			<SELECT NAME="ncpserv">
				<OPTION VALUE="0"$ncpserv_0>No debugging</OPTION>
				<OPTION VALUE="1"$ncpserv_1>Normal debugging</OPTION>
				<OPTION VALUE="99"$ncpserv_99>Maximum debugging</OPTION>
			</SELECT>
		</TD>
	</TR>
	<TR BGCOLOR="#fbf7f1">
		<TD>
			<B>NWCONN:</B>
		</TD>
		<TD ALIGN=RIGHT>
			<SELECT NAME="nwconn">
				<OPTION VALUE="0"$nwconn_0>No debugging</OPTION>
				<OPTION VALUE="1"$nwconn_1>Normal debugging</OPTION>
				<OPTION VALUE="99"$nwconn_99>Maximum debugging</OPTION>
			</SELECT>
		</TD>
	</TR>
	<TR BGCOLOR="#fbf7f1">
		<TD>
			<B>NWCLIENT:</B>
		</TD>
		<TD ALIGN=RIGHT>
			<SELECT NAME="nwclient">
				<OPTION VALUE="0"$nwclient_0>No debugging</OPTION>
				<OPTION VALUE="1"$nwclient_1>Normal debugging</OPTION>
				<OPTION VALUE="99"$nwclient_99>Maximum debugging</OPTION>
			</SELECT>
		</TD>
	</TR>
	<TR BGCOLOR="#fbf7f1">
		<TD>
			<B>NWBIND:</B>
		</TD>
		<TD ALIGN=RIGHT>
			<SELECT NAME="nwbind">
				<OPTION VALUE="0"$nwbind_0>No debugging</OPTION>
				<OPTION VALUE="1"$nwbind_1>Normal debugging</OPTION>
				<OPTION VALUE="99"$nwbind_99>Maximum debugging</OPTION>
			</SELECT>
		</TD>
	</TR>
	<TR BGCOLOR="#fbf7f1">
		<TD>
			<B>NWROUTED:</B>
		</TD>
		<TD ALIGN=RIGHT>
			<SELECT NAME="nwrouted">
				<OPTION VALUE="0"$nwrouted_0>No debugging</OPTION>
				<OPTION VALUE="1"$nwrouted_1>Normal debugging</OPTION>
				<OPTION VALUE="99"$nwrouted_99>Maximum debugging</OPTION>
			</SELECT>
		</TD>
	</TR>
	<TR BGCOLOR="#ece0cf">
		<TD COLSPAN=2>
			<B><FONT>General logging flags</FONT></B><BR>
		</TD>
	</TR>
	<TR BGCOLOR="#fbf7f1">
		<TD>
			<B>NWSERV behaviour:</B>
		</TD>
		<TD ALIGN=RIGHT>
			No logging, run in foreground<INPUT NAME="startup" TYPE=RADIO VALUE="0"$startup_0><BR>
			Run as daemon, enable logging<INPUT NAME="startup" TYPE=RADIO VALUE="1"$startup_1><BR>
		</TD>
	</TR>
	<TR BGCOLOR="#fbf7f1">
		<TD>
			<B>Logfile creation:</B>
		</TD>
		<TD ALIGN=RIGHT>
			Append messages to logfile<INPUT NAME="g_creat" TYPE=RADIO VALUE="0"$g_creat_0><BR>
			Recreate logfile at startup<INPUT NAME="g_creat" TYPE=RADIO VALUE="1"$g_creat_1><BR>
		</TD>
	</TR>
	<TR BGCOLOR="#fbf7f1">
		<TD>
			<B>Log error messages to:</B>
		</TD>
		<TD ALIGN=RIGHT>
			Logfile<INPUT NAME="error" TYPE=RADIO VALUE="0"$error_0><BR>
			<TT>syslog</TT><INPUT NAME="error" TYPE=RADIO VALUE="1"$error_1><BR>
		</TD>
	</TR>
	<TR BGCOLOR="#ece0cf">
		<TD COLSPAN=2>
			<B><FONT>Routing logging flags</FONT></B><BR>
		</TD>
	</TR>
	<TR BGCOLOR="#fbf7f1">
		<TD>
			<B>Write to file every x minutes:</B>
		</TD>
		<TD ALIGN=RIGHT>
			<INPUT NAME="routing_interval" TYPE=TEXT SIZE=32 VALUE="$routing_interval"><BR>
		</TD>
	</TR>
	<TR BGCOLOR="#fbf7f1">
		<TD>
			<B>Logfile creation:</B>
		</TD>
		<TD ALIGN=RIGHT>
			Append messages to logfile<INPUT NAME="r_creat" VALUE="0" TYPE=RADIO$r_creat_0><BR>
			Recreate logfile every time<INPUT NAME="r_creat" VALUE="1" TYPE=RADIO$r_creat_1><BR>
		</TD>
	</TR>
	<TR BGCOLOR="#fbf7f1">
		<TD>
			<B>File:</B>
		</TD>
		<TD ALIGN=RIGHT>
			Keep using the same file<INPUT NAME="r_file" VALUE="0" TYPE=RADIO$r_file_0><BR>
			Write to separate files (<TT>.1</TT>, <TT>.2</TT>, etc)<INPUT NAME="r_file" VALUE="1" TYPE=RADIO$r_file_1><BR>
		</TD>
	</TR>
	<TR BGCOLOR="#d7c0a0">
		<TD>
			<INPUT TYPE=SUBMIT VALUE="OK">
		</TD>
		<TD ALIGN=RIGHT>
			<INPUT TYPE=RESET VALUE="Undo changes"><BR>
		</TD>
	</TR>
</TABLE>
</FORM>

</BODY>
</HTML>
EOF
	}
	elsif( $c[1] eq 'volumes' )
	{
		if( $c[2] eq '' )
		{
			print <<EOF;
HTTP/1.0 200 OK
Content-Type: text/html
$server_id

<HTML>
<HEAD>
<TITLE>SMArT Settings</TITLE>
<link rel="icon" href="/static/favicon.ico" type="image/x-icon">
<link rel="icon" type="image/png" sizes="16x16" href="/static/favicon-16x16.png">
<link rel="icon" type="image/png" sizes="32x32" href="/static/favicon-32x32.png">
<link rel="apple-touch-icon" href="/static/apple-touch-icon.png">
<link rel="icon" type="image/png" sizes="192x192" href="/static/android-chrome-192x192.png">
<link rel="icon" type="image/png" sizes="512x512" href="/static/android-chrome-512x512.png">
<style>
BODY { background:#f6f2ea; color:#2e261d; font-family: Arial, Helvetica, sans-serif; margin:0; padding:14px; }
FORM { margin:0; }
TABLE { border-collapse:separate; border-spacing:0; width:100%; background:#fbf7f1; border:1px solid #ddcfba; border-radius:18px; overflow:hidden; box-shadow:0 6px 18px rgba(80,55,30,0.08); }
TD { padding:10px 12px; }
TR + TR TD { border-top:1px solid #eadfce; }
TR:first-child TD:first-child { border-top-left-radius:18px; }
TR:first-child TD:last-child { border-top-right-radius:18px; }
TR:last-child TD:first-child { border-bottom-left-radius:18px; }
TR:last-child TD:last-child { border-bottom-right-radius:18px; }
INPUT, SELECT, TEXTAREA { font-family: Arial, Helvetica, sans-serif; font-size:14px; }
INPUT[type=TEXT], INPUT[type=PASSWORD], SELECT, TEXTAREA {
  border:1px solid #cdbb9f; border-radius:10px; padding:6px 10px; background:#fffdf9; color:#2e261d;
}
INPUT[type=SUBMIT], INPUT[type=RESET], INPUT[type=BUTTON] {
  border:1px solid #a33d2f; border-radius:10px; padding:8px 14px; background:#b84434; color:#fff; font-weight:bold;
}
A { color:#9f2f26; }
TT { color:#5b4b38; }
</style>
</HEAD>
<BODY BGCOLOR="#f6f2ea">
$settings_nav_bar

<TABLE BORDER=0 CELLSPACING=0 WIDTH=100%>
	<TR BGCOLOR="#d7c0a0">
		<TD>
			<B><FONT SIZE=+2>Volumes</FONT></B>
		</TD>
		<TD ALIGN=RIGHT>
			<IMG SRC="/static/smart_icon.jpg"><BR>
		</TD>
	</TR>
EOF
			@c = getconfig( 1 );
			foreach $c ( @c )
			{
				my @c = split( ' ', $c );
				print <<EOF;
	<TR BGCOLOR="#fbf7f1">
		<TD>
			<A HREF="/settings/volumes/$c[1]"><TT>$c[1]</TT></A> (<TT>$c[2]</TT>)	<!-- NETSCAPE RRRAAARRR -->
		</TD>
		<TD ALIGN=RIGHT>
			<A HREF="/apply/volumes/$c[1]" onclick="return confirm('Delete volume $c[1]?')">Delete</A><BR>
		</TD>
	</TR>
EOF
			}
			print <<EOF;
	<TR BGCOLOR="#d7c0a0">
		<TD COLSPAN=2>
			<B><A HREF="/settings/volumes/add_new">Add new volume</A></B>
		</TD>
	</TR>
</TABLE>
</FORM>

</BODY>
</HTML>
EOF
		}
		else
		{
			$c = getconfigline( '1 ' . $c[2] );
			@c = split( ' ', $c );
			$c = '';
			
			$d = $c[2];
			$d =~ s/[^ik]//g;
			eval( '$c' . $d . ' = " CHECKED";' );
			
			$d = $c[2];
			$d =~ s/[^Tt]//g;
			eval( '$t' . $d . ' = " CHECKED";' );
			
			$m = $c[2];
			$m =~ s/[^m]//g;
			if( $m ne '' )
				{ $m = ' CHECKED'; }
			
			$n = $c[2];
			$n =~ s/[^n]//g;
			if( $n ne '' )
				{ $n = ' CHECKED'; }
			
			$o = $c[2];
			$o =~ s/[^o]//g;
			if( $o ne '' )
				{ $o = ' CHECKED'; }
			
			$p = $c[2];
			$p =~ s/[^p]//g;
			if( $p ne '' )
				{ $p = ' CHECKED'; }
			
			$r = $c[2];
			$r =~ s/[^r]//g;
			if( $r ne '' )
				{ $r = ' CHECKED'; }
			
			$O = $c[2];
			$O =~ s/[^O]//g;
			if( $O ne '' )
				{ $O = ' CHECKED'; }
			
			$N = $c[2];
			$N =~ s/[^N]//g;
			if( $N ne '' )
				{ $N = ' CHECKED'; }
			
			print <<EOF;
HTTP/1.0 200 OK
Content-Type: text/html
$server_id

<HTML>
<HEAD>
<TITLE>SMArT Settings</TITLE>
<link rel="icon" href="/static/favicon.ico" type="image/x-icon">
<link rel="icon" type="image/png" sizes="16x16" href="/static/favicon-16x16.png">
<link rel="icon" type="image/png" sizes="32x32" href="/static/favicon-32x32.png">
<link rel="apple-touch-icon" href="/static/apple-touch-icon.png">
<link rel="icon" type="image/png" sizes="192x192" href="/static/android-chrome-192x192.png">
<link rel="icon" type="image/png" sizes="512x512" href="/static/android-chrome-512x512.png">
<style>
BODY { background:#f6f2ea; color:#2e261d; font-family: Arial, Helvetica, sans-serif; margin:0; padding:14px; }
FORM { margin:0; }
TABLE { border-collapse:separate; border-spacing:0; width:100%; background:#fbf7f1; border:1px solid #ddcfba; border-radius:18px; overflow:hidden; box-shadow:0 6px 18px rgba(80,55,30,0.08); }
TD { padding:10px 12px; }
TR + TR TD { border-top:1px solid #eadfce; }
TR:first-child TD:first-child { border-top-left-radius:18px; }
TR:first-child TD:last-child { border-top-right-radius:18px; }
TR:last-child TD:first-child { border-bottom-left-radius:18px; }
TR:last-child TD:last-child { border-bottom-right-radius:18px; }
INPUT, SELECT, TEXTAREA { font-family: Arial, Helvetica, sans-serif; font-size:14px; }
INPUT[type=TEXT], INPUT[type=PASSWORD], SELECT, TEXTAREA {
  border:1px solid #cdbb9f; border-radius:10px; padding:6px 10px; background:#fffdf9; color:#2e261d;
}
INPUT[type=SUBMIT], INPUT[type=RESET], INPUT[type=BUTTON] {
  border:1px solid #a33d2f; border-radius:10px; padding:8px 14px; background:#b84434; color:#fff; font-weight:bold;
}
A { color:#9f2f26; }
TT { color:#5b4b38; }
</style>
</HEAD>
<BODY BGCOLOR="#f6f2ea">
$settings_nav_bar

<FORM ACTION="/apply/volumes/$c[0]" METHOD=GET>
<TABLE BORDER=0 CELLSPACING=0 WIDTH=100%>
	<TR BGCOLOR="#d7c0a0">
		<TD>
			<B><FONT SIZE=+2>Volume: $c[0]</FONT></B>
		</TD>
		<TD ALIGN=RIGHT>
			<IMG SRC="/static/smart_icon.jpg"><BR>
		</TD>
	</TR>
	<TR BGCOLOR="#fbf7f1">
		<TD>
			<B>Volume name:</B>
		</TD>
		<TD ALIGN=RIGHT>
			<INPUT NAME="name" TYPE=TEXT SIZE=32 VALUE="$c[0]"><BR>
		</TD>
	</TR>
	<TR BGCOLOR="#fbf7f1">
		<TD>
			<B>Unix path:</B>
		</TD>
		<TD ALIGN=RIGHT>
			<INPUT NAME="path" TYPE=TEXT SIZE=32 VALUE="$c[1]"><BR>
		</TD>
	</TR>
	<TR BGCOLOR="#fbf7f1">
		<TD>
			<B>Filename case:</B>
		</TD>
		<TD ALIGN=RIGHT>
			All upper case<INPUT NAME="case" TYPE=RADIO VALUE=""$c><BR>
			Ignore case<INPUT NAME="case" TYPE=RADIO VALUE="i"$ci><BR>
			All lower case<INPUT NAME="case" TYPE=RADIO VALUE="k"$ck><BR>
		</TD>
	</TR>
	<TR BGCOLOR="#fbf7f1">
		<TD>
			<B>Trustees:</B>
		</TD>
		<TD ALIGN=RIGHT>
			Disabled<INPUT NAME="trustee" TYPE=RADIO VALUE=""$t><BR>
			Enabled<INPUT NAME="trustee" TYPE=RADIO VALUE="t"$tt><BR>
			Enabled, unix rights disabled<INPUT NAME="trustee" TYPE=RADIO VALUE="T"$tT><BR>
		</TD>
	</TR>
	<TR BGCOLOR="#ece0cf">
		<TD COLSPAN=2>
			<B><FONT>Additional options</FONT></B><BR>
		</TD>
	</TR>
	<TR BGCOLOR="#fbf7f1">
		<TD>
			<B>Removable:</B>
		</TD>
		<TD ALIGN=RIGHT>
			Enabled<INPUT NAME="m" TYPE=CHECKBOX$m><BR>
		</TD>
	</TR>
	<TR BGCOLOR="#fbf7f1">
		<TD>
			<B>No fixed i-nodes:</B>
		</TD>
		<TD ALIGN=RIGHT>
			Enabled<INPUT NAME="n" TYPE=CHECKBOX$n><BR>
		</TD>
	</TR>
	<TR BGCOLOR="#fbf7f1">
		<TD>
			<B>Single filesystem:</B>
		</TD>
		<TD ALIGN=RIGHT>
			Enabled<INPUT NAME="o" TYPE=CHECKBOX$o><BR>
		</TD>
	</TR>
	<TR BGCOLOR="#fbf7f1">
		<TD>
			<B>Pipe filesystem:</B>
		</TD>
		<TD ALIGN=RIGHT>
			Enabled<INPUT NAME="p" TYPE=CHECKBOX$p><BR>
		</TD>
	</TR>
	<TR BGCOLOR="#fbf7f1">
		<TD>
			<B>Read-only:</B>
		</TD>
		<TD ALIGN=RIGHT>
			Enabled<INPUT NAME="r" TYPE=CHECKBOX$r><BR>
		</TD>
	</TR>
	<TR BGCOLOR="#ece0cf">
		<TD COLSPAN=2>
			<B><FONT>Additional namespaces</FONT></B><BR>
		</TD>
	</TR>
	<TR BGCOLOR="#fbf7f1">
		<TD>
			<B>OS/2 LFN support:</B>
		</TD>
		<TD ALIGN=RIGHT>
			Enabled<INPUT NAME="O" TYPE=CHECKBOX$O><BR>
		</TD>
	</TR>
	<TR BGCOLOR="#fbf7f1">
		<TD>
			<B>NFS support:</B>
		</TD>
		<TD ALIGN=RIGHT>
			Enabled<INPUT NAME="N" TYPE=CHECKBOX$N><BR>
		</TD>
	</TR>
	<TR BGCOLOR="#d7c0a0">
		<TD>
			<INPUT TYPE=SUBMIT VALUE="OK">
		</TD>
		<TD ALIGN=RIGHT>
			<INPUT TYPE=RESET VALUE="Undo changes"><BR>
		</TD>
	</TR>
</TABLE>
</FORM>

</BODY>
</HTML>
EOF
		}
	}
	elsif( $c[1] eq 'devices' )
	{
		if( $c[2] eq '' )
		{
			print <<EOF;
HTTP/1.0 200 OK
Content-Type: text/html
$server_id

<HTML>
<HEAD>
<TITLE>SMArT Settings</TITLE>
<link rel="icon" href="/static/favicon.ico" type="image/x-icon">
<link rel="icon" type="image/png" sizes="16x16" href="/static/favicon-16x16.png">
<link rel="icon" type="image/png" sizes="32x32" href="/static/favicon-32x32.png">
<link rel="apple-touch-icon" href="/static/apple-touch-icon.png">
<link rel="icon" type="image/png" sizes="192x192" href="/static/android-chrome-192x192.png">
<link rel="icon" type="image/png" sizes="512x512" href="/static/android-chrome-512x512.png">
<style>
BODY { background:#f6f2ea; color:#2e261d; font-family: Arial, Helvetica, sans-serif; margin:0; padding:14px; }
FORM { margin:0; }
TABLE { border-collapse:separate; border-spacing:0; width:100%; background:#fbf7f1; border:1px solid #ddcfba; border-radius:18px; overflow:hidden; box-shadow:0 6px 18px rgba(80,55,30,0.08); }
TD { padding:10px 12px; }
TR + TR TD { border-top:1px solid #eadfce; }
TR:first-child TD:first-child { border-top-left-radius:18px; }
TR:first-child TD:last-child { border-top-right-radius:18px; }
TR:last-child TD:first-child { border-bottom-left-radius:18px; }
TR:last-child TD:last-child { border-bottom-right-radius:18px; }
INPUT, SELECT, TEXTAREA { font-family: Arial, Helvetica, sans-serif; font-size:14px; }
INPUT[type=TEXT], INPUT[type=PASSWORD], SELECT, TEXTAREA {
  border:1px solid #cdbb9f; border-radius:10px; padding:6px 10px; background:#fffdf9; color:#2e261d;
}
INPUT[type=SUBMIT], INPUT[type=RESET], INPUT[type=BUTTON] {
  border:1px solid #a33d2f; border-radius:10px; padding:8px 14px; background:#b84434; color:#fff; font-weight:bold;
}
A { color:#9f2f26; }
TT { color:#5b4b38; }
</style>
</HEAD>
<BODY BGCOLOR="#f6f2ea">
$settings_nav_bar

<TABLE BORDER=0 CELLSPACING=0 WIDTH=100%>
	<TR BGCOLOR="#d7c0a0">
		<TD>
			<B><FONT SIZE=+2>Devices</FONT></B>
		</TD>
		<TD ALIGN=RIGHT>
			<IMG SRC="/static/smart_icon.jpg"><BR>
		</TD>
	</TR>
EOF
			@c = getconfig( 4 );
			foreach $c ( @c )
			{
				my @c = split( ' ', $c );
				print <<EOF;
	<TR BGCOLOR="#fbf7f1">
		<TD>
			<A HREF="/settings/devices/$c[1]"><TT>$c[1]</TT></A> ($c[2]/$c[3])
		</TD>
		<TD ALIGN=RIGHT>
			<A HREF="/apply/devices/$c[1]" onclick="return confirm('Delete device $c[1]?')">Delete</A><BR>
		</TD>
	</TR>
EOF
			}
			print <<EOF;
	<TR BGCOLOR="#d7c0a0">
		<TD COLSPAN=2>
			<B><A HREF="/settings/devices/add_new">Add new device</A></B>
		</TD>
	</TR>
</TABLE>
</FORM>

</BODY>
</HTML>
EOF
		}
		else
		{
			$c = getconfigline( '4 ' . $c[2] );
			@c = split( ' ', $c );
			$interface_options = network_interface_options( $c[1] );
			
			$c[2] =~ s/\.//g;
			eval( '$frametype_' . $c[2] . ' = " SELECTED";' );
			
			print <<EOF;
HTTP/1.0 200 OK
Content-Type: text/html
$server_id

<HTML>
<HEAD>
<TITLE>SMArT Settings</TITLE>
<link rel="icon" href="/static/favicon.ico" type="image/x-icon">
<link rel="icon" type="image/png" sizes="16x16" href="/static/favicon-16x16.png">
<link rel="icon" type="image/png" sizes="32x32" href="/static/favicon-32x32.png">
<link rel="apple-touch-icon" href="/static/apple-touch-icon.png">
<link rel="icon" type="image/png" sizes="192x192" href="/static/android-chrome-192x192.png">
<link rel="icon" type="image/png" sizes="512x512" href="/static/android-chrome-512x512.png">
<style>
BODY { background:#f6f2ea; color:#2e261d; font-family: Arial, Helvetica, sans-serif; margin:0; padding:14px; }
FORM { margin:0; }
TABLE { border-collapse:separate; border-spacing:0; width:100%; background:#fbf7f1; border:1px solid #ddcfba; border-radius:18px; overflow:hidden; box-shadow:0 6px 18px rgba(80,55,30,0.08); }
TD { padding:10px 12px; }
TR + TR TD { border-top:1px solid #eadfce; }
TR:first-child TD:first-child { border-top-left-radius:18px; }
TR:first-child TD:last-child { border-top-right-radius:18px; }
TR:last-child TD:first-child { border-bottom-left-radius:18px; }
TR:last-child TD:last-child { border-bottom-right-radius:18px; }
INPUT, SELECT, TEXTAREA { font-family: Arial, Helvetica, sans-serif; font-size:14px; }
INPUT[type=TEXT], INPUT[type=PASSWORD], SELECT, TEXTAREA {
  border:1px solid #cdbb9f; border-radius:10px; padding:6px 10px; background:#fffdf9; color:#2e261d;
}
INPUT[type=SUBMIT], INPUT[type=RESET], INPUT[type=BUTTON] {
  border:1px solid #a33d2f; border-radius:10px; padding:8px 14px; background:#b84434; color:#fff; font-weight:bold;
}
A { color:#9f2f26; }
TT { color:#5b4b38; }
</style>
</HEAD>
<BODY BGCOLOR="#f6f2ea">
$settings_nav_bar

<FORM ACTION="/apply/devices/$c[0]" METHOD=GET>
<TABLE BORDER=0 CELLSPACING=0 WIDTH=100%>
	<TR BGCOLOR="#d7c0a0">
		<TD>
			<B><FONT SIZE=+2>Device: $c[0]</FONT></B>
		</TD>
		<TD ALIGN=RIGHT>
			<IMG SRC="/static/smart_icon.jpg"><BR>
		</TD>
	</TR>
	<TR BGCOLOR="#fbf7f1">
		<TD>
			<B>Network number:</B>
		</TD>
		<TD ALIGN=RIGHT>
			<INPUT NAME="number" TYPE=TEXT SIZE=20 VALUE="$c[0]"><BR>
		</TD>
	</TR>
	<TR BGCOLOR="#fbf7f1">
		<TD>
			<B>Network interface:</B>
		</TD>
		<TD ALIGN=RIGHT>
			<SELECT NAME="interface">
$interface_options			</SELECT><BR>
			<SMALL>Manual override:</SMALL><BR>
			<INPUT NAME="interface_manual" TYPE=TEXT SIZE=20 VALUE=""><BR>
		</TD>
	</TR>
	<TR BGCOLOR="#fbf7f1">
		<TD>
			<B>Frame type:</B>
		</TD>
		<TD ALIGN=RIGHT>
			<SELECT NAME="frametype">
				<OPTION VALUE="ethernet_ii"$frametype_ethernet_ii>Ethernet_II</OPTION>
				<OPTION VALUE="802.2"$frametype_8022>IEEE 802.2</OPTION>
				<OPTION VALUE="802.3"$frametype_8023>IEEE 802.3</OPTION>
				<OPTION VALUE="snap"$frametype_snap>SNAP</OPTION>
				<OPTION VALUE="token"$frametype_token>Token ring</OPTION>
				<OPTION VALUE="auto"$frametype_auto>Automatic detection</OPTION>
			</SELECT>
		</TD>
	</TR>
	<TR BGCOLOR="#fbf7f1">
		<TD>
			<B>Interface delay:</B>
		</TD>
		<TD ALIGN=RIGHT>
			<INPUT NAME="delay" TYPE=TEXT SIZE=20 VALUE="$c[3]"><BR>
		</TD>
	</TR>
	<TR BGCOLOR="#d7c0a0">
		<TD>
			<INPUT TYPE=SUBMIT VALUE="OK">
		</TD>
		<TD ALIGN=RIGHT>
			<INPUT TYPE=RESET VALUE="Undo changes"><BR>
		</TD>
	</TR>
</TABLE>
</FORM>

</BODY>
</HTML>
EOF
		}
	}
	elsif( $c[1] eq 'smart' )
	{
		open( FILE, '<' . $smart_nwclient_path ) or die "Could not open $smart_nwclient_path: $!";
		$x = <FILE>;
		close( FILE );
		
		chomp( $x );
		( $bind_server, $bind_user, $bind_pass ) = split( '[/ ]', $x );
		
		print <<EOF;
HTTP/1.0 200 OK
Content-Type: text/html
$server_id

<HTML>
<HEAD>
<TITLE>SMArT Settings</TITLE>
<link rel="icon" href="/static/favicon.ico" type="image/x-icon">
<link rel="icon" type="image/png" sizes="16x16" href="/static/favicon-16x16.png">
<link rel="icon" type="image/png" sizes="32x32" href="/static/favicon-32x32.png">
<link rel="apple-touch-icon" href="/static/apple-touch-icon.png">
<link rel="icon" type="image/png" sizes="192x192" href="/static/android-chrome-192x192.png">
<link rel="icon" type="image/png" sizes="512x512" href="/static/android-chrome-512x512.png">
<style>
BODY { background:#f6f2ea; color:#2e261d; font-family: Arial, Helvetica, sans-serif; margin:0; padding:14px; }
FORM { margin:0; }
TABLE { border-collapse:separate; border-spacing:0; width:100%; background:#fbf7f1; border:1px solid #ddcfba; border-radius:18px; overflow:hidden; box-shadow:0 6px 18px rgba(80,55,30,0.08); }
TD { padding:10px 12px; }
TR + TR TD { border-top:1px solid #eadfce; }
TR:first-child TD:first-child { border-top-left-radius:18px; }
TR:first-child TD:last-child { border-top-right-radius:18px; }
TR:last-child TD:first-child { border-bottom-left-radius:18px; }
TR:last-child TD:last-child { border-bottom-right-radius:18px; }
INPUT, SELECT, TEXTAREA { font-family: Arial, Helvetica, sans-serif; font-size:14px; }
INPUT[type=TEXT], INPUT[type=PASSWORD], SELECT, TEXTAREA {
  border:1px solid #cdbb9f; border-radius:10px; padding:6px 10px; background:#fffdf9; color:#2e261d;
}
INPUT[type=SUBMIT], INPUT[type=RESET], INPUT[type=BUTTON] {
  border:1px solid #a33d2f; border-radius:10px; padding:8px 14px; background:#b84434; color:#fff; font-weight:bold;
}
A { color:#9f2f26; }
TT { color:#5b4b38; }
</style>
</HEAD>
<BODY BGCOLOR="#f6f2ea">
$settings_nav_bar

<FORM ACTION="/apply/smart" METHOD=GET>
<TABLE BORDER=0 CELLSPACING=0 WIDTH=100%>
	<TR BGCOLOR="#d7c0a0">
		<TD>
			<B><FONT SIZE=+2>SMArT settings</FONT></B>
		</TD>
		<TD ALIGN=RIGHT>
			<IMG SRC="/static/smart_icon.jpg"><BR>
		</TD>
	</TR>
	<TR BGCOLOR="#fbf7f1">
		<TD>
			<B><TT>nwserv.conf</TT> location:</B>
		</TD>
		<TD ALIGN=RIGHT>
			<INPUT NAME="mars_config" TYPE=TEXT SIZE=32 VALUE="$mars_config"><BR>
		</TD>
	</TR>
	<TR BGCOLOR="#ece0cf">
		<TD COLSPAN=2>
			<B><FONT>Bindery server</FONT></B><BR>
		</TD>
	</TR>
	<TR BGCOLOR="#fbf7f1">
		<TD>
			<B>Server name:</B>
		</TD>
		<TD ALIGN=RIGHT>
			<INPUT NAME="bind_server" TYPE=TEXT SIZE=20 VALUE="$bind_server"><BR>
		</TD>
	</TR>
	<TR BGCOLOR="#fbf7f1">
		<TD>
			<B>Supervisor login name:</B>
		</TD>
		<TD ALIGN=RIGHT>
			<INPUT NAME="bind_user" TYPE=TEXT SIZE=20 VALUE="$bind_user"><BR>
		</TD>
	</TR>
	<TR BGCOLOR="#fbf7f1">
		<TD>
			<B>Supervisor password:</B>
		</TD>
		<TD ALIGN=RIGHT>
			<INPUT NAME="bind_pass" TYPE=PASSWORD SIZE=20 VALUE="$bind_pass"><BR>
		</TD>
	</TR>
	<TR BGCOLOR="#d7c0a0">
		<TD>
			<INPUT TYPE=SUBMIT VALUE="OK">
		</TD>
		<TD ALIGN=RIGHT>
			<INPUT TYPE=RESET VALUE="Undo changes"><BR>
		</TD>
	</TR>
</TABLE>
</FORM>

</BODY>
</HTML>
EOF
	}
	elsif( $c[1] eq 'users' )
	{
		$server = get_server();
		
		if( $c[2] eq '' )
		{
			print <<EOF;
HTTP/1.0 200 OK
Content-Type: text/html
$server_id

<HTML>
<HEAD>
<TITLE>SMArT Settings</TITLE>
<link rel="icon" href="/static/favicon.ico" type="image/x-icon">
<link rel="icon" type="image/png" sizes="16x16" href="/static/favicon-16x16.png">
<link rel="icon" type="image/png" sizes="32x32" href="/static/favicon-32x32.png">
<link rel="apple-touch-icon" href="/static/apple-touch-icon.png">
<link rel="icon" type="image/png" sizes="192x192" href="/static/android-chrome-192x192.png">
<link rel="icon" type="image/png" sizes="512x512" href="/static/android-chrome-512x512.png">
<style>
BODY { background:#f6f2ea; color:#2e261d; font-family: Arial, Helvetica, sans-serif; margin:0; padding:14px; }
FORM { margin:0; }
TABLE { border-collapse:separate; border-spacing:0; width:100%; background:#fbf7f1; border:1px solid #ddcfba; border-radius:18px; overflow:hidden; box-shadow:0 6px 18px rgba(80,55,30,0.08); }
TD { padding:10px 12px; }
TR + TR TD { border-top:1px solid #eadfce; }
TR:first-child TD:first-child { border-top-left-radius:18px; }
TR:first-child TD:last-child { border-top-right-radius:18px; }
TR:last-child TD:first-child { border-bottom-left-radius:18px; }
TR:last-child TD:last-child { border-bottom-right-radius:18px; }
INPUT, SELECT, TEXTAREA { font-family: Arial, Helvetica, sans-serif; font-size:14px; }
INPUT[type=TEXT], INPUT[type=PASSWORD], SELECT, TEXTAREA {
  border:1px solid #cdbb9f; border-radius:10px; padding:6px 10px; background:#fffdf9; color:#2e261d;
}
INPUT[type=SUBMIT], INPUT[type=RESET], INPUT[type=BUTTON] {
  border:1px solid #a33d2f; border-radius:10px; padding:8px 14px; background:#b84434; color:#fff; font-weight:bold;
}
A { color:#9f2f26; }
TT { color:#5b4b38; }
</style>
</HEAD>
<BODY BGCOLOR="#f6f2ea">
$settings_nav_bar

<TABLE BORDER=0 CELLSPACING=0 WIDTH=100%>
	<TR BGCOLOR="#d7c0a0">
		<TD>
			<B><FONT SIZE=+2>Users</FONT></B>
		</TD>
		<TD ALIGN=RIGHT>
			<IMG SRC="/static/smart_icon.jpg"><BR>
		</TD>
	</TR>
EOF
			@c = sort( split( "\n", `nwbols -t 1 -S $server` ) );
			foreach $c ( @c )
			{
				my @c = split( ' ', $c );
				print <<EOF;
	<TR BGCOLOR="#fbf7f1">
		<TD>
			<A HREF="/settings/users/$c[0]">$c[0]</A>
		</TD>
		<TD ALIGN=RIGHT>
			<A HREF="/apply/users/$c[0]" onclick="return confirm('Delete user $c[0]?')">Delete</A><BR>
		</TD>
	</TR>
EOF
			}
			print <<EOF;
	<TR BGCOLOR="#d7c0a0">
		<TD COLSPAN=2>
			<B><A HREF="/settings/users/add_new">Add new user</A></B>
		</TD>
	</TR>
</TABLE>
</FORM>

</BODY>
</HTML>
EOF
		}
		else
		{
			$unix_user_list = ''; 
			$group_list = '';
			@allgroups = sort( split( "\n", `nwbols -S $server -t 2` ) );
			if( $c[2] ne 'add_new' )
			{
				$fullname = read_property_string( $c[2], 1, 'IDENTIFICATION' );
				$unix_user = read_property_string( $c[2], 1, 'UNIX_USER' );
				foreach $u ( unix_userlist() )
				{
					if( $u->{name} eq $unix_user )
						{ $unix_user_list .= "\t\t\t" . '<OPTION VALUE="' . $u->{name} . '" SELECTED>' . $u->{name} . '</OPTION>' . "\n"; }
					else
						{ $unix_user_list .= "\t\t\t" . '<OPTION VALUE="' . $u->{name} . '">' . $u->{name} . '</OPTION>' . "\n"; }
				}
				@groups = read_property_list( $c[2], 1, 'GROUPS_I\\\'M_IN' );
				foreach $g ( @allgroups )
				{
					$g =~ s/ .*//;
					if( grep( /^$g$/, @groups ) )
						{ $group_list .= "\t\t\t" . $g . '<INPUT TYPE=CHECKBOX NAME="group_' . $g . '" CHECKED><BR>' . "\n"; }
					else
						{ $group_list .= "\t\t\t" . $g . '<INPUT TYPE=CHECKBOX NAME="group_' . $g . '"><BR>' . "\n"; }
				}
			}
			else
			{
				foreach $u ( unix_userlist() )
				{
					$unix_user_list .= "\t\t\t" . '<OPTION VALUE="' . $u->{name} . '">' . $u->{name} . '</OPTION>' . "\n";
				}
				foreach $g ( @allgroups )
				{
					$g =~ s/ .*//;
					$group_list .= "\t\t\t" . $g . '<INPUT TYPE=CHECKBOX NAME="group_' . $g . '"><BR>' . "\n";
				}
			}
			
			print <<EOF;
HTTP/1.0 200 OK
Content-Type: text/html
$server_id

<HTML>
<HEAD>
<TITLE>SMArT Settings</TITLE>
<link rel="icon" href="/static/favicon.ico" type="image/x-icon">
<link rel="icon" type="image/png" sizes="16x16" href="/static/favicon-16x16.png">
<link rel="icon" type="image/png" sizes="32x32" href="/static/favicon-32x32.png">
<link rel="apple-touch-icon" href="/static/apple-touch-icon.png">
<link rel="icon" type="image/png" sizes="192x192" href="/static/android-chrome-192x192.png">
<link rel="icon" type="image/png" sizes="512x512" href="/static/android-chrome-512x512.png">
<style>
BODY { background:#f6f2ea; color:#2e261d; font-family: Arial, Helvetica, sans-serif; margin:0; padding:14px; }
FORM { margin:0; }
TABLE { border-collapse:separate; border-spacing:0; width:100%; background:#fbf7f1; border:1px solid #ddcfba; border-radius:18px; overflow:hidden; box-shadow:0 6px 18px rgba(80,55,30,0.08); }
TD { padding:10px 12px; }
TR + TR TD { border-top:1px solid #eadfce; }
TR:first-child TD:first-child { border-top-left-radius:18px; }
TR:first-child TD:last-child { border-top-right-radius:18px; }
TR:last-child TD:first-child { border-bottom-left-radius:18px; }
TR:last-child TD:last-child { border-bottom-right-radius:18px; }
INPUT, SELECT, TEXTAREA { font-family: Arial, Helvetica, sans-serif; font-size:14px; }
INPUT[type=TEXT], INPUT[type=PASSWORD], SELECT, TEXTAREA {
  border:1px solid #cdbb9f; border-radius:10px; padding:6px 10px; background:#fffdf9; color:#2e261d;
}
INPUT[type=SUBMIT], INPUT[type=RESET], INPUT[type=BUTTON] {
  border:1px solid #a33d2f; border-radius:10px; padding:8px 14px; background:#b84434; color:#fff; font-weight:bold;
}
A { color:#9f2f26; }
TT { color:#5b4b38; }
</style>
</HEAD>
<BODY BGCOLOR="#f6f2ea">
$settings_nav_bar

<FORM ACTION="/apply/users/$c[2]" METHOD=GET>
<TABLE BORDER=0 CELLSPACING=0 WIDTH=100%>
	<TR BGCOLOR="#d7c0a0">
		<TD>
			<B><FONT SIZE=+2>User: $c[2]</FONT></B>
		</TD>
		<TD ALIGN=RIGHT>
			<IMG SRC="/static/smart_icon.jpg"><BR>
		</TD>
	</TR>
EOF

			if( $c[2] eq 'add_new' )
			{
				print <<EOF;
	<TR BGCOLOR="#fbf7f1">
		<TD>
			<B>Account name:</B>
		</TD>
		<TD ALIGN=RIGHT>
			<INPUT NAME="name" TYPE=TEXT SIZE=20><BR>
		</TD>
	</TR>
EOF
			}
			
			print <<EOF;
	<TR BGCOLOR="#fbf7f1">
		<TD>
			<B>Full name:</B>
		</TD>
		<TD ALIGN=RIGHT>
			<INPUT NAME="fullname" TYPE=TEXT SIZE=20 VALUE="$fullname"><BR>
		</TD>
	</TR>
	<TR BGCOLOR="#fbf7f1">
		<TD>
			<B>Password:</B>
		</TD>
		<TD ALIGN=RIGHT>
			<INPUT NAME="password" TYPE=PASSWORD SIZE=20><BR>
		</TD>
	</TR>
	<TR BGCOLOR="#fbf7f1">
		<TD>
			<B>UNIX user:</B>
		</TD>
		<TD ALIGN=RIGHT>
			<SELECT NAME="unix_user" SIZE=5>
$unix_user_list			</SELECT>
		</TD>
	</TR>
	<TR BGCOLOR="#fbf7f1">
		<TD>
			<B>Groups belonged to:</B>
		</TD>
		<TD ALIGN=RIGHT>
$group_list		</TD>
	</TR>
	<TR BGCOLOR="#d7c0a0">
		<TD>
			<INPUT TYPE=SUBMIT VALUE="OK">
		</TD>
		<TD ALIGN=RIGHT>
			<INPUT TYPE=RESET VALUE="Undo changes"><BR>
		</TD>
	</TR>
</TABLE>
</FORM>

</BODY>
</HTML>
EOF
		}
	}
	elsif( $c[1] eq 'groups' )
	{
		$server = get_server();
		
		if( $c[2] eq '' )
		{
			print <<EOF;
HTTP/1.0 200 OK
Content-Type: text/html
$server_id

<HTML>
<HEAD>
<TITLE>SMArT Settings</TITLE>
<link rel="icon" href="/static/favicon.ico" type="image/x-icon">
<link rel="icon" type="image/png" sizes="16x16" href="/static/favicon-16x16.png">
<link rel="icon" type="image/png" sizes="32x32" href="/static/favicon-32x32.png">
<link rel="apple-touch-icon" href="/static/apple-touch-icon.png">
<link rel="icon" type="image/png" sizes="192x192" href="/static/android-chrome-192x192.png">
<link rel="icon" type="image/png" sizes="512x512" href="/static/android-chrome-512x512.png">
<style>
BODY { background:#f6f2ea; color:#2e261d; font-family: Arial, Helvetica, sans-serif; margin:0; padding:14px; }
FORM { margin:0; }
TABLE { border-collapse:separate; border-spacing:0; width:100%; background:#fbf7f1; border:1px solid #ddcfba; border-radius:18px; overflow:hidden; box-shadow:0 6px 18px rgba(80,55,30,0.08); }
TD { padding:10px 12px; }
TR + TR TD { border-top:1px solid #eadfce; }
TR:first-child TD:first-child { border-top-left-radius:18px; }
TR:first-child TD:last-child { border-top-right-radius:18px; }
TR:last-child TD:first-child { border-bottom-left-radius:18px; }
TR:last-child TD:last-child { border-bottom-right-radius:18px; }
INPUT, SELECT, TEXTAREA { font-family: Arial, Helvetica, sans-serif; font-size:14px; }
INPUT[type=TEXT], INPUT[type=PASSWORD], SELECT, TEXTAREA {
  border:1px solid #cdbb9f; border-radius:10px; padding:6px 10px; background:#fffdf9; color:#2e261d;
}
INPUT[type=SUBMIT], INPUT[type=RESET], INPUT[type=BUTTON] {
  border:1px solid #a33d2f; border-radius:10px; padding:8px 14px; background:#b84434; color:#fff; font-weight:bold;
}
A { color:#9f2f26; }
TT { color:#5b4b38; }
</style>
</HEAD>
<BODY BGCOLOR="#f6f2ea">
$settings_nav_bar

<TABLE BORDER=0 CELLSPACING=0 WIDTH=100%>
	<TR BGCOLOR="#d7c0a0">
		<TD>
			<B><FONT SIZE=+2>Groups</FONT></B>
		</TD>
		<TD ALIGN=RIGHT>
			<IMG SRC="/static/smart_icon.jpg"><BR>
		</TD>
	</TR>
EOF
			@c = sort( split( "\n", `nwbols -t 2 -S $server` ) );
			foreach $c ( @c )
			{
				my @c = split( ' ', $c );
				print <<EOF;
	<TR BGCOLOR="#fbf7f1">
		<TD>
			<A HREF="/settings/groups/$c[0]">$c[0]</A>
		</TD>
		<TD ALIGN=RIGHT>
			<A HREF="/apply/groups/$c[0]" onclick="return confirm('Delete group $c[0]?')">Delete</A><BR>
		</TD>
	</TR>
EOF
			}
			print <<EOF;
	<TR BGCOLOR="#d7c0a0">
		<TD COLSPAN=2>
			<B><A HREF="/settings/groups/add_new">Add new group</A></B>
		</TD>
	</TR>
</TABLE>
</FORM>

</BODY>
</HTML>
EOF
		}
		else
		{
			@all = sort( split( "\n", `nwbols -S $server` ) );
			$man_list = '';
			if( $c[2] ne 'add_new' )
			{
				$fullname = read_property_string( $c[2], 2, 'IDENTIFICATION' );
				@mans = read_property_list( $c[2], 2, 'OBJ_SUPERVISORS' );
				foreach $g ( @all )
				{
					my @c = split( ' ', $g );
					if( $c[2] == 1 or $c[2] == 2 )
					{
						if( grep( /^$c[0]$/, @mans ) )
							{ $man_list .= "\t\t\t" . '(' . ( $c[2] == 1 ? 'user' : 'group' ) . ') ' . $c[0] . '<INPUT TYPE=CHECKBOX NAME="man_' . $c[2] . '_' . $c[0] . '" CHECKED><BR>' . "\n"; }
						else
							{ $man_list .= "\t\t\t" . '(' . ( $c[2] == 1 ? 'user' : 'group' ) . ') ' . $c[0] . '<INPUT TYPE=CHECKBOX NAME="man_' . $c[2] . '_' . $c[0] . '"><BR>' . "\n"; }
					}
				}
			}
			else
			{
				foreach $g ( @all )
				{
					my @c = split( ' ', $g );
					if( $c[2] == 1 or $c[2] == 2 )
					{
						$man_list .= "\t\t\t" . '(' . ( $c[2] == 1 ? 'user' : 'group' ) . ') ' . $c[0] . '<INPUT TYPE=CHECKBOX NAME="man_' . $c[2] . '_' . $c[0] . '"><BR>' . "\n";
					}
				}
			}
			
			print <<EOF;
HTTP/1.0 200 OK
Content-Type: text/html
$server_id

<HTML>
<HEAD>
<TITLE>SMArT Settings</TITLE>
<link rel="icon" href="/static/favicon.ico" type="image/x-icon">
<link rel="icon" type="image/png" sizes="16x16" href="/static/favicon-16x16.png">
<link rel="icon" type="image/png" sizes="32x32" href="/static/favicon-32x32.png">
<link rel="apple-touch-icon" href="/static/apple-touch-icon.png">
<link rel="icon" type="image/png" sizes="192x192" href="/static/android-chrome-192x192.png">
<link rel="icon" type="image/png" sizes="512x512" href="/static/android-chrome-512x512.png">
<style>
BODY { background:#f6f2ea; color:#2e261d; font-family: Arial, Helvetica, sans-serif; margin:0; padding:14px; }
FORM { margin:0; }
TABLE { border-collapse:separate; border-spacing:0; width:100%; background:#fbf7f1; border:1px solid #ddcfba; border-radius:18px; overflow:hidden; box-shadow:0 6px 18px rgba(80,55,30,0.08); }
TD { padding:10px 12px; }
TR + TR TD { border-top:1px solid #eadfce; }
TR:first-child TD:first-child { border-top-left-radius:18px; }
TR:first-child TD:last-child { border-top-right-radius:18px; }
TR:last-child TD:first-child { border-bottom-left-radius:18px; }
TR:last-child TD:last-child { border-bottom-right-radius:18px; }
INPUT, SELECT, TEXTAREA { font-family: Arial, Helvetica, sans-serif; font-size:14px; }
INPUT[type=TEXT], INPUT[type=PASSWORD], SELECT, TEXTAREA {
  border:1px solid #cdbb9f; border-radius:10px; padding:6px 10px; background:#fffdf9; color:#2e261d;
}
INPUT[type=SUBMIT], INPUT[type=RESET], INPUT[type=BUTTON] {
  border:1px solid #a33d2f; border-radius:10px; padding:8px 14px; background:#b84434; color:#fff; font-weight:bold;
}
A { color:#9f2f26; }
TT { color:#5b4b38; }
</style>
</HEAD>
<BODY BGCOLOR="#f6f2ea">
$settings_nav_bar

<FORM ACTION="/apply/groups/$c[2]" METHOD=GET>
<TABLE BORDER=0 CELLSPACING=0 WIDTH=100%>
	<TR BGCOLOR="#d7c0a0">
		<TD>
			<B><FONT SIZE=+2>Group: $c[2]</FONT></B>
		</TD>
		<TD ALIGN=RIGHT>
			<IMG SRC="/static/smart_icon.jpg"><BR>
		</TD>
	</TR>
EOF

			if( $c[2] eq 'add_new' )
			{
				print <<EOF;
	<TR BGCOLOR="#fbf7f1">
		<TD>
			<B>Group name:</B>
		</TD>
		<TD ALIGN=RIGHT>
			<INPUT NAME="name" TYPE=TEXT SIZE=20><BR>
		</TD>
	</TR>
EOF
			}
			
			print <<EOF;
	<TR BGCOLOR="#fbf7f1">
		<TD>
			<B>Full name:</B>
		</TD>
		<TD ALIGN=RIGHT>
			<INPUT NAME="fullname" TYPE=TEXT SIZE=20 VALUE="$fullname"><BR>
		</TD>
	</TR>
	<TR BGCOLOR="#fbf7f1">
		<TD>
			<B>Group managers:</B>
		</TD>
		<TD ALIGN=RIGHT>
$man_list		</TD>
	</TR>
	<TR BGCOLOR="#d7c0a0">
		<TD>
			<INPUT TYPE=SUBMIT VALUE="OK">
		</TD>
		<TD ALIGN=RIGHT>
			<INPUT TYPE=RESET VALUE="Undo changes"><BR>
		</TD>
	</TR>
</TABLE>
</FORM>

</BODY>
</HTML>
EOF
		}
	}
	elsif( $c[1] eq 'queues' )
	{
		$server = get_server();
		
		if( $c[2] eq '' )
		{
			print <<EOF;
HTTP/1.0 200 OK
Content-Type: text/html
$server_id

<HTML>
<HEAD>
<TITLE>SMArT Settings</TITLE>
<link rel="icon" href="/static/favicon.ico" type="image/x-icon">
<link rel="icon" type="image/png" sizes="16x16" href="/static/favicon-16x16.png">
<link rel="icon" type="image/png" sizes="32x32" href="/static/favicon-32x32.png">
<link rel="apple-touch-icon" href="/static/apple-touch-icon.png">
<link rel="icon" type="image/png" sizes="192x192" href="/static/android-chrome-192x192.png">
<link rel="icon" type="image/png" sizes="512x512" href="/static/android-chrome-512x512.png">
<style>
BODY { background:#f6f2ea; color:#2e261d; font-family: Arial, Helvetica, sans-serif; margin:0; padding:14px; }
FORM { margin:0; }
TABLE { border-collapse:separate; border-spacing:0; width:100%; background:#fbf7f1; border:1px solid #ddcfba; border-radius:18px; overflow:hidden; box-shadow:0 6px 18px rgba(80,55,30,0.08); }
TD { padding:10px 12px; }
TR + TR TD { border-top:1px solid #eadfce; }
TR:first-child TD:first-child { border-top-left-radius:18px; }
TR:first-child TD:last-child { border-top-right-radius:18px; }
TR:last-child TD:first-child { border-bottom-left-radius:18px; }
TR:last-child TD:last-child { border-bottom-right-radius:18px; }
INPUT, SELECT, TEXTAREA { font-family: Arial, Helvetica, sans-serif; font-size:14px; }
INPUT[type=TEXT], INPUT[type=PASSWORD], SELECT, TEXTAREA {
  border:1px solid #cdbb9f; border-radius:10px; padding:6px 10px; background:#fffdf9; color:#2e261d;
}
INPUT[type=SUBMIT], INPUT[type=RESET], INPUT[type=BUTTON] {
  border:1px solid #a33d2f; border-radius:10px; padding:8px 14px; background:#b84434; color:#fff; font-weight:bold;
}
A { color:#9f2f26; }
TT { color:#5b4b38; }
</style>
</HEAD>
<BODY BGCOLOR="#f6f2ea">
$settings_nav_bar

<TABLE BORDER=0 CELLSPACING=0 WIDTH=100%>
	<TR BGCOLOR="#d7c0a0">
		<TD>
			<B><FONT SIZE=+2>Print queues</FONT></B>
		</TD>
		<TD ALIGN=RIGHT>
			<IMG SRC="/static/smart_icon.jpg"><BR>
		</TD>
	</TR>
EOF
			@c = sort( split( "\n", `nwbols -t 3 -S $server` ) );
			foreach $c ( @c )
			{
				my @c = split( ' ', $c );
				print <<EOF;
	<TR BGCOLOR="#fbf7f1">
		<TD>
			<A HREF="/settings/queues/$c[0]">$c[0]</A>
		</TD>
		<TD ALIGN=RIGHT>
			<A HREF="/apply/queues/$c[0]" onclick="return confirm('Delete queue $c[0]?')">Delete</A><BR>
		</TD>
	</TR>
EOF
			}
			print <<EOF;
	<TR BGCOLOR="#d7c0a0">
		<TD COLSPAN=2>
			<B><A HREF="/settings/queues/add_new">Add new print queue</A></B>
		</TD>
	</TR>
</TABLE>
</FORM>

</BODY>
</HTML>
EOF
		}
		else
		{
			@all = sort( split( "\n", `nwbols -S $server` ) );
			$man_list = '';
			if( $c[2] ne 'add_new' )
			{
				$unix_print = read_property_string( $c[2], 3, 'Q_UNIX_PRINT' );
				$spool_dir = read_property_string( $c[2], 3, 'Q_DIRECTORY' );
			}
			
			print <<EOF;
HTTP/1.0 200 OK
Content-Type: text/html
$server_id

<HTML>
<HEAD>
<TITLE>SMArT Settings</TITLE>
<link rel="icon" href="/static/favicon.ico" type="image/x-icon">
<link rel="icon" type="image/png" sizes="16x16" href="/static/favicon-16x16.png">
<link rel="icon" type="image/png" sizes="32x32" href="/static/favicon-32x32.png">
<link rel="apple-touch-icon" href="/static/apple-touch-icon.png">
<link rel="icon" type="image/png" sizes="192x192" href="/static/android-chrome-192x192.png">
<link rel="icon" type="image/png" sizes="512x512" href="/static/android-chrome-512x512.png">
<style>
BODY { background:#f6f2ea; color:#2e261d; font-family: Arial, Helvetica, sans-serif; margin:0; padding:14px; }
FORM { margin:0; }
TABLE { border-collapse:separate; border-spacing:0; width:100%; background:#fbf7f1; border:1px solid #ddcfba; border-radius:18px; overflow:hidden; box-shadow:0 6px 18px rgba(80,55,30,0.08); }
TD { padding:10px 12px; }
TR + TR TD { border-top:1px solid #eadfce; }
TR:first-child TD:first-child { border-top-left-radius:18px; }
TR:first-child TD:last-child { border-top-right-radius:18px; }
TR:last-child TD:first-child { border-bottom-left-radius:18px; }
TR:last-child TD:last-child { border-bottom-right-radius:18px; }
INPUT, SELECT, TEXTAREA { font-family: Arial, Helvetica, sans-serif; font-size:14px; }
INPUT[type=TEXT], INPUT[type=PASSWORD], SELECT, TEXTAREA {
  border:1px solid #cdbb9f; border-radius:10px; padding:6px 10px; background:#fffdf9; color:#2e261d;
}
INPUT[type=SUBMIT], INPUT[type=RESET], INPUT[type=BUTTON] {
  border:1px solid #a33d2f; border-radius:10px; padding:8px 14px; background:#b84434; color:#fff; font-weight:bold;
}
A { color:#9f2f26; }
TT { color:#5b4b38; }
</style>
</HEAD>
<BODY BGCOLOR="#f6f2ea">
$settings_nav_bar

<FORM ACTION="/apply/queues/$c[2]" METHOD=GET>
<TABLE BORDER=0 CELLSPACING=0 WIDTH=100%>
	<TR BGCOLOR="#d7c0a0">
		<TD>
			<B><FONT SIZE=+2>Print queue: $c[2]</FONT></B>
		</TD>
		<TD ALIGN=RIGHT>
			<IMG SRC="/static/smart_icon.jpg"><BR>
		</TD>
	</TR>
EOF

			if( $c[2] eq 'add_new' )
			{
				print <<EOF;
	<TR BGCOLOR="#fbf7f1">
		<TD>
			<B>Queue name:</B>
		</TD>
		<TD ALIGN=RIGHT>
			<INPUT NAME="name" TYPE=TEXT SIZE=32><BR>
		</TD>
	</TR>
EOF
			}
			
			print <<EOF;
	<TR BGCOLOR="#fbf7f1">
		<TD>
			<B>Unix printing command:</B>
		</TD>
		<TD ALIGN=RIGHT>
			<INPUT NAME="unix_print" TYPE=TEXT SIZE=32 VALUE="$unix_print"><BR>
		</TD>
	</TR>
	<TR BGCOLOR="#fbf7f1">
		<TD>
			<B>Spool directory:</B>
		</TD>
		<TD ALIGN=RIGHT>
			<INPUT NAME="spool_dir" TYPE=TEXT SIZE=32 VALUE="$spool_dir"><BR>
		</TD>
	</TR>
	<TR BGCOLOR="#d7c0a0">
		<TD>
			<INPUT TYPE=SUBMIT VALUE="OK">
		</TD>
		<TD ALIGN=RIGHT>
			<INPUT TYPE=RESET VALUE="Undo changes"><BR>
		</TD>
	</TR>
</TABLE>
</FORM>

</BODY>
</HTML>
EOF
		}
	}
	else
	{
		error( 404 );
	}
}
