surveillance.pl
99 lines of code
1
#!/usr/local/bin/perl
2
3
($<,$>) = (getpwnam('nobody'), getpwnam('nobody')) or die $!;
4
5
binmode(STDIN, ":utf8");
6
binmode(STDOUT, ":utf8");
7
8
# must have's!
9
use strict;
10
use warnings;
11
use CGI::Carp qw(fatalsToBrowser);
12
use DBI;
13
use URI::Escape;
14
15
use lib "/var/www/html/Pm";
16
17
use Html qw(pre_html_header header html_end debug_banner);
18
use Html2 qw(tag br hr);
19
use Bc_chef qw(cookie_get);
20
use Bc_misc qw(get_param referrer get_params_asHash);
21
use Bc_sql qw(sql_execute
22
              get_constant
23
              user_exists
24
              $QUERY_PAGE
25
              $QUERY_UID
26
              $LOGGEDIN
27
28
              $DB
29
             );
30
use Redir qw(notice_redir error_redir);
31
use User qw(isUserAdmin $USER_DATA);
32
use Security qw(banned); Security::count_hits();
33
34
my $DEBUG = 1;
35
my $DEBUG_STR = "";
36
37
my %params = get_params_asHash();
38
39
my $output;
40
41
if (not user_exists($LOGGEDIN) or banned($LOGGEDIN) or not isUserAdmin($LOGGEDIN)) {
42
  my $msg =  "Access Denied";
43
  if ($DEBUG) { $msg .= " (surveillance.pl)"; }
44
  $output = error_redir("/", $msg);
45
} else {
46
  ############################################################
47
  ### YOUR CONTENT HERE
48
  $output = pre_html_header();
49
  $output .= header(
50
                   "Surveillance",
51
                   "?nobg_img=1&nogrid=1",
52
                   0,
53
                   "setTimeout(removeMsg, " . get_constant("REMOVE_MSG_TIMEOUT") . ");",
54
                   "",
55
                   "style=\"padding: 2px;\""
56
                  );
57
58
  if ($DEBUG) {
59
    if (keys %params) {
60
      foreach my $key (sort keys %params) {
61
        $params{$key} =~ s/^ *//;
62
        $params{$key} =~ s/ *$//;
63
        $DEBUG_STR .= "$key = $params{$key}" . br;
64
      }
65
    } else {
66
      { my %str;
67
        $str{tag} = "div";
68
        $str{class} = "red-panel";
69
        $str{innerHTML} = "No Params Given!";
70
71
        $DEBUG_STR .= tag(\%str);
72
      }
73
      $DEBUG_STR .= br;
74
    }
75
76
    $output .= debug_banner("Surveillance", $DEBUG_STR, 1);
77
  }
78
79
  use RTSP::Client;
80
  my $client = new RTSP::Client(
81
      port               => 554,
82
      client_port_range  => '6970-6971',
83
      transport_protocol => 'RTP/AVP;unicast',
84
      address            => '192.168.1.29',
85
      media_path         => '/live/ch00_0',
86
  );
87
88
  $client->open or die $!;
89
  $client->setup;
90
  $client->play;
91
92
  ### END YOUR CONTENT
93
  $output .= html_end();
94
  ############################################################
95
}
96
97
print $output;
98
99
exit 1;