All debian changes related to smb2www cgi scripts.

Index: smb2www/cgi-bin/smb2www.pl
===================================================================
--- smb2www.orig/cgi-bin/smb2www.pl	2011-02-05 16:14:38.000000000 +0100
+++ smb2www/cgi-bin/smb2www.pl	2011-02-05 16:15:07.000000000 +0100
@@ -22,6 +22,9 @@
 use strict;
 use smb2www;
 
+# Debian: is smb2www enabled?
+CheckEnabled() or exit 0;
+
 my @smbout = GetSMBGroups;
 
 header ("$text{welcome}");
@@ -33,7 +36,7 @@
 
 table ( 
   "<FORM ACTION=\"$cfg{cgiroot}/smbshr.pl\" METHOD=GET>".
-    "<INPUT TYPE=\"image\" BORDER=0 SRC=$cfg{imgroot}/$cfg{icon_computer}>",
+    "<INPUT TYPE=\"image\" BORDER=0 SRC=\"$cfg{imgroot}/$cfg{icon_computer}\" ALT=\"$text{submit}\" VALUE=\"$text{submit}\">",
   "",
   "<DIV ALIGN=right><INPUT TYPE=\"text\" name=\"host\" SIZE=\"15\"></DIV>".
     "<INPUT TYPE=\"hidden\" NAME=\"group\" VALUE=\"\">".
Index: smb2www/cgi-bin/smb2www.pm
===================================================================
--- smb2www.orig/cgi-bin/smb2www.pm	2011-02-05 16:14:38.000000000 +0100
+++ smb2www/cgi-bin/smb2www.pm	2011-02-05 16:17:39.000000000 +0100
@@ -26,6 +26,7 @@
 package smb2www;
 use Exporter ();
 
+use IO::File;
 use MIME::Base64;
 use Time::Local; # for lmtime
 use strict;
@@ -36,19 +37,24 @@
               GetSMBTar GetSMBFile GetSMBDir GetSMBShr 
               GetSMBHosts GetSMBGroups
               httptime MakeAuth GetAuth 
-              SendHostMessage
+              SendHostMessage GetCmdOutput
+              CheckEnabled
 );
 
 ## Configuration
 
-%cfg = ();
-open (CONFIG,"/usr/local/smb2www/etc/smb2www.conf") or die "SMB2WWW: No config file found.";
-while (<CONFIG>) {
-  if ( $_ =~ /([\w\_]+)\s*=\s*(.+)/ ) {
-     $cfg{$1} = $2;
+%cfg=();
+my $cfg_file;
+foreach $cfg_file (("/usr/share/smb2www/smb2www.default","/etc/smb2www/smb2www.conf")) {
+  open (CONFIG, $cfg_file) or die "SMB2WWW: No config file found.";
+  while (<CONFIG>) {
+    next if (/^#/);
+    if (/([\w\_]+)\s*=\s*(.+)/ ) {
+       $cfg{$1} = $2;
+    }
   }
+  close CONFIG;
 }
-close CONFIG;
 
 ## Multi-language support
 
@@ -63,6 +69,18 @@
 
 ## Common procedures
 
+# Get output of command without using shell
+# usage: @output = GetCmdOutput(@args)
+sub GetCmdOutput {
+        my @args = @_;
+	# fork and exec command
+        open (OUT, '-|')
+                || exec { $args[0] } @args;
+        my @out=<OUT>;
+        close OUT;
+        return @out;
+}
+
 # Nasty URL encoding/decoding stuff
 sub urlDecode{
   my $value= $_[0];
@@ -86,17 +104,16 @@
   my %query = ();
   my $input;
   if ($ENV{'REQUEST_METHOD'} eq "POST") {
-    chomp ($input = urlDecode <STDIN>);
+    chomp ($input = <STDIN>);
   } else {
     $input = $ENV{'QUERY_STRING'};
   }
-  my @security = split ( ';',$input); 
-  my @qs = split ( '&', $security[0]);
+  my @qs = split ( '&', $input);
   my $entry;
   foreach $entry (@qs) {
     if ($entry =~ /([\w]+)=([^\&\?]+)/) {
-      my $key = $1;
-      my $value = $2;
+      my $key = urlDecode($1);
+      my $value = urlDecode($2);
       $query{$key}=$value;
     }
   }
@@ -111,7 +128,7 @@
 # Return a HTML image tag
 
 sub image {
-  return "<IMG SRC=\"$cfg{imgroot}/$_[0]\" BORDER=0 ALIGN=CENTER ALT=\"$_[1]\">";
+  return "<IMG SRC=\"$cfg{imgroot}/$_[0]\" BORDER=\"0\" ALIGN=\"MIDDLE\" ALT=\"$_[1]\">";
 };
 
 # Return a HTML table entry 
@@ -135,24 +152,24 @@
   my $url; 
   my $pwa;
   if ( $auth eq "" ) {
-    $pwa = "user=$user&pass=$pass"
+    $pwa = "user=$user&amp;pass=$pass"
   } else {
     $pwa = "auth=$auth";
   }
   if ( (lc $type) eq "file" ) { 
-   $url = "$cfg{cgiroot}/smbfile.pl/$host/$share/$size/$dir?$pwa&lm=".lmtime($date);
+   $url = "$cfg{cgiroot}/smbfile.pl/$host/$share/$size/$dir?$pwa&amp;lm=".lmtime($date);
   } elsif ( (lc $type) eq "tar" ) {
    $url = "$cfg{cgiroot}/smbtar.pl/$host/$share$dir?$pwa";
   } elsif ( (lc $type) eq "dir" ) {
-      $url = "$cfg{cgiroot}/smbdir.pl?group=$group&master=$master&host=$host&share=$share&dir=$dir&$pwa";
+      $url = "$cfg{cgiroot}/smbdir.pl?group=$group&amp;master=$master&amp;host=$host&amp;share=$share&amp;dir=$dir&amp;$pwa";
   } elsif ( (lc $type) eq "share" ) {
-   $url = "$cfg{cgiroot}/smbshr.pl?group=$group&master=$master&host=$host";
+   $url = "$cfg{cgiroot}/smbshr.pl?group=$group&amp;master=$master&amp;host=$host";
   } elsif ( (lc $type) eq "group" ) {
-   $url = "$cfg{cgiroot}/smbgrp.pl?group=$group&master=$master";
+   $url = "$cfg{cgiroot}/smbgrp.pl?group=$group&amp;master=$master";
   } elsif ( (lc $type) eq "all" ) {
    $url = "$cfg{cgiroot}/smb2www.pl";
   } elsif ( (lc $type) eq "msg" ) {
-   $url = "$cfg{cgiroot}/smbmsg.pl?group=$group&master=$master&host=$host";
+   $url = "$cfg{cgiroot}/smbmsg.pl?group=$group&amp;master=$master&amp;host=$host";
   } else {
    $url = $_[0]; # Act stupid when acted stupid upon
   } 
@@ -163,14 +180,14 @@
 
 sub mimetype {
   my $test = lc $_[0];
-  my $type;
-  open MIME, $cfg{mimetype};
+  my $type = "";
+ if (open MIME, $cfg{mimetype}) {
   RULE: while ( <MIME> ) {
     my $line = $_;
     if ( not ($line =~ /^$/) and not ($line =~ /^#/) ) {
       if ( $line =~ /^([^\s]+)\s+([\w\ ]+)/ ) {
         $type = $1;
-        if ( $2 =~ /$test/ ) {
+        if ( $2 =~ /\b$test\b/o ) {
           last RULE;
         } else {
           $type = "";
@@ -179,6 +196,7 @@
     }
   }
   close MIME;
+ }
   $type = "application/octet-stream" if ($type eq "");
   return $type; 
 }
@@ -227,11 +245,38 @@
 
 sub header {
   my $exp = expiretime;
+  my $charset = (defined $text{'lang_charset'}) ? $text{'lang_charset'} : 'ISO-8859-1';
   print << "EOF";
 Cache-Control: $cfg{cache}
 Expires: $exp
-Content-type: text/html
+Content-type: text/html; charset=$charset
+
+EOF
 
+  if (defined $cfg{html_header_file} and -f $cfg{html_header_file}) {
+    my ($head_file, $head_data, %head_conf);
+    $head_file = IO::File->new($cfg{html_header_file}, 'r') or
+      die "Could not open $cfg{html_head_file}: $!";
+    $head_data = join("\n", $head_file->getlines);
+    $head_file->close;
+
+    %head_conf = (TITLE => $_[0],
+		  REFRESH => (not $_[1] =~ /norefresh/) ?
+		  "<META HTTP-EQUIV=\"refresh\" content=\"$cfg{refresh}\">\n" :
+		  '',
+		  CHARSET => $charset,
+		  IMGROOT => $cfg{imgroot},
+		  BACKGROUND => $cfg{background},
+		  LINK => $cfg{link},
+		  VLINK => $cfg{vlink});
+
+    for my $key (keys %head_conf) {
+	$head_data =~ s/%$key%/$head_conf{$key}/g;
+    }
+
+    print $head_data;
+  } else {
+    print << "EOF";
 <HTML>
 
 <HEAD>
@@ -243,23 +288,41 @@
 More information about SMB2WWW is at http://samba.anu.edu.au/samba/smb2www
 //-->
 EOF
-if (not $_[1] =~ /norefresh/ ) {
-  print "<META HTTP-EQUIV=\"refresh\" content=\"$cfg{refresh}\">\n";
-}
-print << "EOF";
+    if (not $_[1] =~ /norefresh/ ) {
+	print "<META HTTP-EQUIV=\"refresh\" content=\"$cfg{refresh}\">\n";
+    }
+    print << "EOF";
+<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=$charset">
 </HEAD>
 <BODY background="$cfg{imgroot}/$cfg{background}" LINK="$cfg{"link"}" VLINK="$cfg{vlink}">
 <CENTER><H1>$_[0]</H1></CENTER>
 <HR WIDTH=\"75%\">
 <TABLE>
 EOF
-};
+  }
+}
 
 # Finishing the page
 
 sub trailer {
-  my $help = href("$cfg{cgiroot}/smbhelp.pl", image ($cfg{icon_help},"Help")."<H3>HELP</H3>");
-  print << "EOF";
+  my ($help, $lang_sup) = @_; # the arguments are used only by smbhelp
+  $help = href("$cfg{cgiroot}/smbhelp.pl", image ($cfg{icon_help},"$text{help}")."<BR><FONT SIZE=\"+1\"><B>$text{help2}</B></FONT><BR>") unless defined $help;
+  $lang_sup = "" unless defined $lang_sup;
+
+
+  if (defined $cfg{html_trailer_file} and -f $cfg{html_trailer_file}) {
+    my ($trailer_file, $trailer_data);
+    $trailer_file = IO::File->new($cfg{html_trailer_file}, 'r') or
+      die "Could not open $cfg{html_trailer_file}: $!";
+    $trailer_data = join("\n", $trailer_file->getlines);
+    $trailer_file->close;
+
+    $trailer_data =~ s/%HELP%/$help/g;
+    $trailer_data =~ s/%LANG_SUPPORT%/$lang_sup/g;
+
+    print $trailer_data;
+  } else {
+    print << "EOF";
 </TABLE>
 <HR WIDTH="75%">
 <CENTER>
@@ -269,6 +332,7 @@
 </BODY>
 </HTML>
 EOF
+  }
 };
 
 ## Interfacing perl with smbclient
@@ -296,9 +360,9 @@
   } else { 
     $pass = "-N";
   }
-  my @args = ("$cfg{bindir}/smbclient", "//$host/$share", "$pass", "$user",  "-d
-  0", "-c", "get \"$file\" $target");
-  return system (@args);
+  my @args = ("$cfg{bindir}/smbclient", "//$host/$share", "$pass", "$user", "-E", "-d0", "-c", "get \"$file\" $target");
+  exec { $args[0] } (@args);
+### NOT REACHED ###
 }
 
 # Makes a TAR of //$host/$share/$dir, using $user and $pass, to $target.
@@ -317,8 +381,9 @@
   } else { 
     $pass = "-N";
   }
-  my @args = ("$cfg{bindir}/smbclient", "//$host/$share", "$pass", "$user", "-d0 ", "-D", "$dir", "-Tc", "$target");
-  return system (@args);
+  my @args = ("$cfg{bindir}/smbclient", "//$host/$share", "$pass", "$user", "-E", "-d0", "-D", "$dir", "-Tcq", "$target");
+  exec { $args[0] } (@args);
+### NOT REACHED ###
 }
 
 # Return an array with sorted dir and filelisting
@@ -331,9 +396,9 @@
   if (! $user eq "") { $user = "-U".$user }
   if ( $pass eq "") { $pass = "-N" } 
 
-  my $lookup = "$cfg{bindir}/smbclient \"//$_[0]/$_[1]\" \"$pass\" $user -d0 -c ls -D \"$_[2]\"";
+  my @lookup = ("$cfg{bindir}/smbclient", "//$_[0]/$_[1]", "$pass", "$user", "-d0", "-c", "ls", "-D", "$_[2]");
 
-  my @out = `$lookup`;
+  my @out = GetCmdOutput(@lookup);
   my $line;
   foreach $line ( @out ) {
     if ($line =~ /^  ([\S ]*\S|[\.]+) {5,}([HDRSA]+) +([0-9]+)  (\S[\S ]+\S)$/g) {
@@ -371,16 +436,16 @@
 sub GetSMBShr {
   my $share = $_[0];
   my @ret = ();
-  my $lookup = "$cfg{bindir}/smbclient -L \"$share\" -d0";
-  my @out = `$lookup`;
+  my @lookup = ("$cfg{bindir}/smbclient", "-L", "$share", "-d0", "-N");
+  my @out = GetCmdOutput(@lookup);
   my $line = shift @out;
-  while ( (not $line =~ /^\s+Sharename/) and ($#out >= -1) ) {
+  while ( (not $line =~ /^\s+Sharename/) and ($#out > -1) ) {
     $line = shift @out;
   }
-  if ($#out >= 0) {
+  if ($#out > 0) {
     $line = shift @out;
     $line = shift @out; 
-    while ( (not $line =~ /^$/) and ($#out >= -1) ) {
+    while ( (not $line =~ /^$/) ) {
       if ( $line =~ /^\s+(\S[\S ]{0,14})\s+(Disk|Printer|IPC)\s+([\S ]*)/ ) {
         my $rec = {};
         my $nearname = $1;
@@ -393,6 +458,7 @@
         }
         push @ret, $rec;
       } 
+      last if $#out < 0;
       $line = shift @out;
     }
   }
@@ -406,25 +472,24 @@
 sub GetSMBHosts {
   my ($workgroup,$host) = @_;
   my @ret = ();
-  my $lookup = "$cfg{bindir}/smbclient -L \"$host\" -W \"$workgroup\" -d0";
-  my @out = `$lookup`;
+  my @lookup = ("$cfg{bindir}/smbclient", "-L", "$host", "-W", "$workgroup", "-d0", "-N");
+  my @out = GetCmdOutput(@lookup);
   my $line = shift @out;
 
-  while ((not $line =~ /^This machine has a browse list/) and ($#out >= -1) ) {
+  while ((not $line =~ /^\s+Server\s+Comment$/) and ($#out > -1) ) {
     $line = shift @out;
   }
-  if ($#out >= -1) {
-    $line = shift @out;
-    $line = shift @out;
+  if ($#out > 0) {
     $line = shift @out;
     $line = shift @out;
-    while ((not $line =~ /^$/) and ($#out >= -1)) {
-      if ( $line =~ /^\t([\S ]*\S) {5,}(\S[\S ]*|\S|)$/ ) {
+    while ((not $line =~ /^$/)) {
+      if ( $line =~ /^\s+([\S ]*\S) {5,}\s?(\S[\S ]*|\S|)$/ ) {
         my $rec = {};
         $rec->{name} = $1;
         $rec->{comment} = $2;
         push @ret, $rec;
       }
+      last if $#out < 0;
       $line = shift @out;
     }
   }
@@ -437,25 +502,24 @@
 
 sub GetSMBGroups {
   my @ret = ();
-  my $lookup = "$cfg{bindir}/smbclient -L \"$cfg{masterbrowser}\" -d0";
-  my @out = `$lookup`;
+  my @lookup = ("$cfg{bindir}/smbclient", "-L", "$cfg{masterbrowser}", "-d0", "-N");
+  my @out = GetCmdOutput(@lookup);
   my $line = shift @out;
 
-  while ((not $line =~ /^This machine has a workgroup list/) and ($#out >= 0) ) {
+  while ((not $line =~ /^\s+Workgroup\s+Master$/) and ($#out > -1) ) {
     $line = shift @out;
   }
-  if ($#out >= -1) {
+  if ($#out > 0) {
     $line = shift @out;
     $line = shift @out;
-    $line = shift @out;
-    $line = shift @out;
-    while ((not $line =~ /^$/) and ($#out >= -1) ) {
-      if ( $line =~ /^\t([\S ]*\S) {2,}(\S[\S ]*)$/ ) {
+    while ((not $line =~ /^$/ )) {
+      if ( $line =~ /^\s+([\S ]*\S) {2,}\s?(\S[\S ]*)$/ ) {
         my $rec = {};
         $rec->{name} = $1;
         $rec->{master} = $2;
         push @ret, $rec;
       }
+      last if $#out < 0;
       $line = shift @out;
     }
   }
@@ -464,7 +528,15 @@
 
 sub SendHostMessage {
   my ($host,$msg) = @_;
-  open ( MSGOUT, "| $cfg{bindir}/smbclient -M \"$host\" -d0 -U \"smb2www\" > /dev/null" );
+  my @args = ("$cfg{bindir}/smbclient", "-M", "$host", "-d0", "-U", "smb2www");
+  # fork...
+  if (not open (MSGOUT, '|-')) {
+	# ...child process, reopen STDOUT to /dev/null and exec smbclient
+	close (STDOUT);
+	open STDOUT, ">/dev/null";
+	exec { $args[0] } @args;
+  }
+  # ... parent process
   print MSGOUT $msg;
   close MSGOUT;
   return "OK";
@@ -498,3 +570,24 @@
   return split (":",($uudec ^ $crypt))
 }
 
+# Debian:
+sub CheckEnabled() {
+
+  return 1 if ((exists $cfg{'enabled'}) and ($cfg{'enabled'} eq 'yes'));
+  print << "EOF";
+Content-type: text/html; charset=ISO-8859-1
+
+<HTML>
+<HEAD>
+  <TITLE>SMB2WWW is disabled!</TITLE>
+</HEAD>
+<BODY>
+  <H1>SMB2WWW is disabled!</H1>
+  <P ALIGN=\"center\">
+   SMB2WWW is currently disabled.<BR>
+   To enable it, please run the <I>dpkg-reconfigure smb2www</I> command.
+  </P>
+</BODY>
+EOF
+  return 0;
+}
Index: smb2www/cgi-bin/smbdir.pl
===================================================================
--- smb2www.orig/cgi-bin/smbdir.pl	2011-02-05 16:14:38.000000000 +0100
+++ smb2www/cgi-bin/smbdir.pl	2011-02-05 16:15:07.000000000 +0100
@@ -22,15 +22,18 @@
 use strict;
 use smb2www;
 
+# Debian: is smb2www enabled?
+CheckEnabled() or exit 0;
+
 select STDOUT; $| = 1;
 
 $ENV{'USER'}=$cfg{username};
 
 my %all=decode_query;
-my $key = "";
-foreach $key (keys %all) {
-  $all{$key} = urlDecode $all{$key};
-}
+# my $key = "";
+# foreach $key (keys %all) {
+#  $all{$key} = urlDecode $all{$key};
+# }
 
 if (($all{auth} eq "") and ($all{user}.$all{pass} ne "")) {
   my $auth = MakeAuth ($all{user},$all{pass});
Index: smb2www/cgi-bin/smbfile.pl
===================================================================
--- smb2www.orig/cgi-bin/smbfile.pl	2011-02-05 16:14:38.000000000 +0100
+++ smb2www/cgi-bin/smbfile.pl	2011-02-05 16:15:07.000000000 +0100
@@ -22,6 +22,9 @@
 use strict;
 use smb2www;
 
+# Debian: is smb2www enabled?
+CheckEnabled() or exit 0;
+
 sub URLParse {
   my ($host, $share, $file, $user, $pass) = @_;
   $file =~ s/^(.*)\/([^\/]*)$/$1$2/ ;
@@ -29,7 +32,7 @@
   if ( $pass ne "") {
     if ( $user eq "" ) { $user = "-Uguest" }
   } else { $pass = "-N" }
-  my @input = `$cfg{bindir}/smbclient //$host/$share $pass $user -d2 -c "get \"$file\" -"`;
+  my @input = GetCmdOutput(("$cfg{bindir}/smbclient", "//$host/$share", "$pass", "$user", "-d0", "-E", "-c", "get \"$file\" -"));
   my $url = $input[1];
   chop $url;
   if ( $url =~ /URL\=(.*)/ ) {
@@ -48,20 +51,20 @@
 my @muddy="";
 my $filesize=""; my $filename = "";
 my %all=decode_query;
-my $key = "";
-foreach $key (keys %all) {
-  $all{$key} = urlDecode $all{$key};
-}
+# my $key = "";
+# foreach $key (keys %all) {
+#   $all{$key} = urlDecode $all{$key};
+# }
 
 if ($all{auth} ne "") {
   ($all{user},$all{pass}) = GetAuth ("$all{auth}");
 }
 
 if ($info =~ /\/([\w\s\$\#\!\-\_\%\'\.\+]+)\/([\w\s\$\#\!\-\_\%\'\.\+]+)\/([\d]+)\/(.*)/) {
-   $all{host} = $1;
-   $all{share} = $2;
-   $filesize= $3;
-   $filename = $4;
+   $all{host} = urlDecode($1);
+   $all{share} = urlDecode($2);
+   $filesize= urlDecode($3);
+   $filename = urlDecode($4);
 }
 
 my $ext="";
@@ -80,4 +83,5 @@
   if ( $filesize ne "") { print "Content-Length: $filesize\n" }
   print "Content-type: ".mimetype ($ext)."\n\n";
   GetSMBFile ("$all{host}","$all{share}","$filename","$all{user}","$all{pass}");
+###  NOT REACHED  ###
 }
Index: smb2www/cgi-bin/smbgrp.pl
===================================================================
--- smb2www.orig/cgi-bin/smbgrp.pl	2011-02-05 16:14:38.000000000 +0100
+++ smb2www/cgi-bin/smbgrp.pl	2011-02-05 16:15:07.000000000 +0100
@@ -22,11 +22,14 @@
 use strict;
 use smb2www;
 
+# Debian: is smb2www enabled?
+CheckEnabled() or exit 0;
+
 my %all=decode_query;
-my $key = "";
-foreach $key (keys %all) {
-  $all{$key} = urlDecode $all{$key};
-}
+# my $key = "";
+# foreach $key (keys %all) {
+#   $all{$key} = urlDecode $all{$key};
+# }
 
 my @smbout = GetSMBHosts ("$all{group}","$all{master}");
 
Index: smb2www/cgi-bin/smbhelp.pl
===================================================================
--- smb2www.orig/cgi-bin/smbhelp.pl	2011-02-05 16:14:38.000000000 +0100
+++ smb2www/cgi-bin/smbhelp.pl	2011-02-05 16:15:07.000000000 +0100
@@ -2,6 +2,8 @@
 
 use smb2www;
 
+# Debian: is smb2www enabled?
+CheckEnabled() or exit 0;
 
 %helptext = ();
 open (HELPTEXT,"$cfg{cfgdir}/$cfg{language}_help.lang") or die "SMB2WWW: No language support found for $cfg{language} help";
@@ -16,14 +18,14 @@
 
 header ($helptext{header},"norefresh");
 
-print "</TABLE>\n";
+print "<TR><TD></TD></TR></TABLE>\n";
 print "<H1>$helptext{header}</H1>\n";
 print "<BR>\n";
 print $helptext{info}."\n";
 print "<BR>\n";
 print $helptext{info2}."\n";
 print "<BR>\n";
-print "<TABLE>\n";
+print "<TABLE CELLPADDING=\"5\" BORDER=\"0\">\n";
 table ( image ($cfg{icon_other}, "$text{othernet}"),
         "$helptext{othernet}",
         ""
@@ -61,9 +63,5 @@
         ""
 );
 my $referer=$ENV{'HTTP_REFERER'} || "$cfg{cgiroot}/smb2www.pl";
-print "</TABLE>\n";
-print "<CENTER>".href("$referer", image($cfg{icon_all}, "$text{ent_net}"))."<H3>$text{goback}</H3></CENTER>";
-print "<HR WIDTH=\"75%\">\n";
-print "<CENTER>Comments/remarks/kudos to:<i>remco\@samba.anu.edu.au</i></CENTER>\n";
-print "<H6>Language support for $cfg{language} created by $text{lang_author}</H6>\n";
-print "</BODY></HTML>\n";
+trailer( href("$referer", image($cfg{icon_all}, "$text{ent_net}") . "<BR><FONT SIZE=\"+1\"><B>$text{goback}</B></FONT><BR>" ),
+	"<H6>Language support for " . ucfirst($cfg{language}) . " created by $text{lang_author}</H6>" );
Index: smb2www/cgi-bin/smbmsg.pl
===================================================================
--- smb2www.orig/cgi-bin/smbmsg.pl	2011-02-05 16:14:38.000000000 +0100
+++ smb2www/cgi-bin/smbmsg.pl	2011-02-05 16:15:07.000000000 +0100
@@ -7,10 +7,13 @@
 use strict;
 use smb2www;
 
+# Debian: is smb2www enabled?
+CheckEnabled() or exit 0;
+
 my %all=decode_query;
 
 sub Message_OK {
-  header ("$text{message_ok}");
+  header ("$text{message_ok}", "norefresh");
   print "<CENTER>\n";
   print image($cfg{icon_message},"$text{sendmsg}");
   print "<P>\n";
@@ -18,14 +21,14 @@
   trailer;
 }
 
-my $key = "";
+# my $key = "";
 my $back = "";
-foreach $key (keys %all) {
-  $all{$key} = urlDecode $all{$key};
-}
+# foreach $key (keys %all) {
+#   $all{$key} = urlDecode $all{$key};
+# }
 
 if ($all{'mesg'} eq '') {
-  header ("$text{sendmsg}");
+  header ("$text{sendmsg}", "norefresh");
   print "<H1>$text{sendmsg2} ";
 
   if ( $all{'host'} eq '' ) {
Index: smb2www/cgi-bin/smbshr.pl
===================================================================
--- smb2www.orig/cgi-bin/smbshr.pl	2011-02-05 16:14:38.000000000 +0100
+++ smb2www/cgi-bin/smbshr.pl	2011-02-05 16:15:24.000000000 +0100
@@ -22,11 +22,14 @@
 use strict;
 use smb2www;
 
+# Debian: is smb2www enabled?
+CheckEnabled() or exit 0;
+
 my %all=decode_query;
-my $key = "";
-foreach $key (keys %all) {
-  $all{$key} = urlDecode $all{$key};
-}
+# my $key = "";
+# foreach $key (keys %all) {
+#   $all{$key} = urlDecode $all{$key};
+# }
 
 $ENV{'USER'}=$cfg{username};
 
@@ -40,7 +43,7 @@
 
      table ( href ("$cfg{cgiroot}/smb2www.pl", image ($cfg{icon_all},"$text{network}")),
              "",
-             "<H3>".href ("$cfg{cgiroot}/smb2www.pl",'$text{ent_net}')."</H3>",
+             "<H3>".href ("$cfg{cgiroot}/smb2www.pl","$text{ent_net}")."</H3>",
              "",
              ""
      );
@@ -95,7 +98,7 @@
             "<INPUT TYPE=\"hidden\" NAME=\"group\" VALUE=\"$all{'group'}\">".
             "<INPUT TYPE=\"hidden\" NAME=\"master\" VALUE=\"$all{'master'}\">".
             "<INPUT TYPE=\"hidden\" NAME=\"host\" VALUE=\"$all{'host'}\">",
-           "<INPUT TYPE=\"image\" BORDER=0 SRC=\"$cfg{imgroot}/$cfg{icon_share}\">",
+           "<INPUT TYPE=\"image\" BORDER=\"0\" SRC=\"$cfg{imgroot}/$cfg{icon_share}\" VALUE=\"$text{submit}\" ALT=\"$text{submit}\">",
            "<INPUT TYPE=\"text\" name=\"share\" SIZE=\"15\">",
            "</FORM>\n"
          );
Index: smb2www/cgi-bin/smbtar.pl
===================================================================
--- smb2www.orig/cgi-bin/smbtar.pl	2011-02-05 16:14:38.000000000 +0100
+++ smb2www/cgi-bin/smbtar.pl	2011-02-05 16:15:07.000000000 +0100
@@ -22,6 +22,9 @@
 use smb2www;
 use strict;
 
+# Debian: is smb2www enabled?
+CheckEnabled() or exit 0;
+
 select STDOUT; $| = 1;
 $ENV{'USER'}=$cfg{username};
 
@@ -29,14 +32,14 @@
 
 my $info = $ENV{'PATH_INFO'};
 if ($info =~ /\/([\w\s\$\#\!\-\_\%\'\.]+)\/([\w\s\$\#\!\-\_\%\'\.]+)\/(.*)/) {
-   $all{host} = $1;
-   $all{share} = $2;
-   $all{dir} = $3;
-}
-my $key = "";
-foreach $key (keys %all) {
-  $all{$key} = urlDecode $all{$key};
+   $all{host} = urlDecode($1);
+   $all{share} = urlDecode($2);
+   $all{dir} = urlDecode($3);
 }
+# my $key = "";
+# foreach $key (keys %all) {
+#   $all{$key} = urlDecode $all{$key};
+# }
 
 if ($all{auth} ne "") {
   ($all{user},$all{pass}) = GetAuth ("$all{auth}");
@@ -50,4 +53,5 @@
 print "Content-type: application/x-tar\n\n";
 
 GetSMBTar ("$all{host}","$all{share}","$dir","$all{user}","$all{pass}");
+###  NOT REACHED  ###
 
