File: smbmsg.pl

package info (click to toggle)
smb2www 980804-41
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd, stretch
  • size: 648 kB
  • ctags: 67
  • sloc: perl: 1,089; sh: 87; makefile: 26
file content (82 lines) | stat: -rwxr-xr-x 1,890 bytes parent folder | download | duplicates (9)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
#! /usr/bin/perl

#  This file smbmsg.pl Copyright 1998 Edward Rudd <eddie@omegaware.com>
#  Modifications by Remco van Mook, 1998.


use strict;
use smb2www;

# Debian: is smb2www enabled?
CheckEnabled() or exit 0;

my %all=decode_query;

sub Message_OK {
  header ("$text{message_ok}", "norefresh");
  print "<CENTER>\n";
  print image($cfg{icon_message},"$text{sendmsg}");
  print "<P>\n";
  print href("$all{back}","$text{goback}")."\n";
  trailer;
}

# my $key = "";
my $back = "";
# foreach $key (keys %all) {
#   $all{$key} = urlDecode $all{$key};
# }

if ($all{'mesg'} eq '') {
  header ("$text{sendmsg}", "norefresh");
  print "<H1>$text{sendmsg2} ";

  if ( $all{'host'} eq '' ) {
    print "$text{workgroup} $all{group}";
  } else {
    print "$all{host}";
  }
  print ":</H1>\n";
  if ($all{'back'} eq '') {
    $back = "$ENV{'HTTP_REFERER'}";
  } else {
    $back = "$all{'back'}";
  }
  print << "EOF" ;
<CENTER><FORM ACTION=\"$cfg{cgiroot}/smbmsg.pl\" METHOD=get>
<TEXTAREA name="mesg" rows=6 cols=50></TEXTAREA><P>
<INPUT type="submit" value="$text{submit}">
<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="hidden" name="back" value="$back">
</FORM>
EOF
trailer;

} else {
  if ( $all{host} eq '' ) {
    my @smbout = GetSMBHosts ("$all{master}","$all{group}");

    if ( $#smbout < 0 ) {
      header ("$text{no_group}");
      print "<H1>$text{no_group2}</H1><BR>\n";
      table ( 
      href (shref("all"),image ($cfg{icon_all},"$text{network}")),
      "<H3>$text{ent_net}</H3>",
      ""
      );
      trailer;
      exit;
    }
    my $line = "";
    foreach $line ( @smbout ) {
      SendHostMessage ($line->{name},$all{'mesg'});
    }
    Message_OK;
  } else {
    SendHostMessage ($all{'host'},$all{'mesg'});
    Message_OK;
  }

}