Merge branch 'storageareas' into tesla
commit
866c875312
|
@ -634,7 +634,7 @@ insert into Users VALUES (NULL,'admin',password('admin'),'',1,'View','Edit','Edi
|
|||
--
|
||||
-- Add a sample filter to purge the oldest 100 events when the disk is 95% full
|
||||
--
|
||||
insert into Filters values (NULL,'PurgeWhenFull','{"sort_field":"Id","terms":[{"val":0,"attr":"Archived","op":"="},{"cnj":"and","val":95,"attr":"DiskPercent","op":">="}],"limit":100,"sort_asc":1}',0,0,0,0,0,0,'',1,1,0);
|
||||
insert into Filters values (NULL,'PurgeWhenFull','{"sort_field":"Id","terms":[{"val":0,"attr":"Archived","op":"="},{"cnj":"and","val":95,"attr":"DiskPercent","op":">="}],"limit":100,"sort_asc":1}',0,0,0,0,0,0,'',1,0,1,0);
|
||||
|
||||
--
|
||||
-- Add in some sample control protocol definitions
|
||||
|
@ -766,15 +766,16 @@ CREATE TABLE Maps (
|
|||
CREATE TABLE MontageLayouts (
|
||||
`Id` int(10) unsigned NOT NULL auto_increment,
|
||||
`Name` TEXT NOT NULL,
|
||||
`Positions` JSON,
|
||||
`Positions` LONGTEXT,
|
||||
/*`Positions` JSON,*/
|
||||
PRIMARY KEY (`Id`)
|
||||
);
|
||||
|
||||
INSERT INTO MontageLayouts (`Name`,`Positions`) VALUES ('Freeform', '{ "default":{"float":"left"} }' );
|
||||
INSERT INTO MontageLayouts (`Name`,`Positions`) VALUES ('2 Wide', '{ "default":{"float":"left", "width":"49%"} }' );
|
||||
INSERT INTO MontageLayouts (`Name`,`Positions`) VALUES ('3 Wide', '{ "default":{"float":"left", "width":"33%"} }' );
|
||||
INSERT INTO MontageLayouts (`Name`,`Positions`) VALUES ('4 Wide', '{ "default":{"float":"left", "width":"24.5%"} }' );
|
||||
INSERT INTO MontageLayouts (`Name`,`Positions`) VALUES ('5 Wide', '{ "default":{"float":"left", "width":"19%"} }' );
|
||||
INSERT INTO MontageLayouts (`Name`,`Positions`) VALUES ('Freeform', '{ "default":{"float":"left","left":"0px","right":"0px","top":"0px","bottom":"0px"} }' );
|
||||
INSERT INTO MontageLayouts (`Name`,`Positions`) VALUES ('2 Wide', '{ "default":{"float":"left", "width":"49%","left":"0px","right":"0px","top":"0px","bottom":"0px"} }' );
|
||||
INSERT INTO MontageLayouts (`Name`,`Positions`) VALUES ('3 Wide', '{ "default":{"float":"left", "width":"33%","left":"0px","right":"0px","top":"0px","bottom":"0px"} }' );
|
||||
INSERT INTO MontageLayouts (`Name`,`Positions`) VALUES ('4 Wide', '{ "default":{"float":"left", "width":"24.5%","left":"0px","right":"0px","top":"0px","bottom":"0px"} }' );
|
||||
INSERT INTO MontageLayouts (`Name`,`Positions`) VALUES ('5 Wide', '{ "default":{"float":"left", "width":"19%","left":"0px","right":"0px","top":"0px","bottom":"0px"} }' );
|
||||
|
||||
--
|
||||
-- Apply the initial configuration
|
||||
|
|
|
@ -13,7 +13,7 @@ SET @s = (SELECT IF(
|
|||
CREATE TABLE MontageLayouts (
|
||||
`Id` int(10) unsigned NOT NULL auto_increment,
|
||||
`Name` TEXT NOT NULL,
|
||||
`Positions` JSON,
|
||||
`Positions` LONGTEXT,
|
||||
PRIMARY KEY (`Id`)
|
||||
);
|
||||
"
|
||||
|
@ -22,18 +22,20 @@ SET @s = (SELECT IF(
|
|||
PREPARE stmt FROM @s;
|
||||
EXECUTE stmt;
|
||||
|
||||
DELETE FROM MontageLayouts WHERE Name IN ('Freeform','2 Wide','3 Wide','4 Wide','5 Wide');
|
||||
|
||||
SET @s = ( SELECT IF(
|
||||
(SELECT COUNT(*) FROM MontageLayouts WHERE Name='Freeform') > 0,
|
||||
"SELECT 'Freeform already in layouts'",
|
||||
"INSERT INTO MontageLayouts (`Name`,`Positions`) VALUES ('Freeform', '{ "default":{"float":"left"} }' );"
|
||||
'INSERT INTO MontageLayouts (`Name`,`Positions`) VALUES (\'Freeform\', \'{"default":{"float":"left","position":"relative","left":"0px","right":"0px","top":"0px","bottom":"0px"}}\');'
|
||||
) );
|
||||
PREPARE stmt FROM @s;
|
||||
EXECUTE stmt;
|
||||
|
||||
SET @s = ( SELECT IF(
|
||||
(SELECT COUNT(*) FROM MontageLayouts WHERE Name='2 Wide') > 0,
|
||||
"SELECT '2 Wide already in layouts'",
|
||||
"INSERT INTO MontageLayouts (`Name`,`Positions`) VALUES ('2 Wide', '{ "default":{"float":"left", "width":"49%"} }' );";
|
||||
"SELECT '2 Wide already in layouts'",
|
||||
'INSERT INTO MontageLayouts (`Name`,`Positions`) VALUES (\'2 Wide\', \'{"default":{"float":"left","position":"relative","width":"49%","left":"0px","right":"0px","top":"0px","bottom":"0px"}}\');'
|
||||
) );
|
||||
PREPARE stmt FROM @s;
|
||||
EXECUTE stmt;
|
||||
|
@ -41,7 +43,7 @@ EXECUTE stmt;
|
|||
SET @s = ( SELECT IF(
|
||||
(SELECT COUNT(*) FROM MontageLayouts WHERE Name='3 Wide') > 0,
|
||||
"SELECT '3 Wide already in layouts'",
|
||||
"INSERT INTO MontageLayouts (`Name`,`Positions`) VALUES ('3 Wide', '{ "default":{"float":"left", "width":"33%"} }' );"
|
||||
'INSERT INTO MontageLayouts (`Name`,`Positions`) VALUES (\'3 Wide\', \'{"default":{"float":"left","position":"relative","width":"33%","left":"0px","right":"0px","top":"0px","bottom":"0px"}}\');'
|
||||
) );
|
||||
PREPARE stmt FROM @s;
|
||||
EXECUTE stmt;
|
||||
|
@ -49,15 +51,16 @@ EXECUTE stmt;
|
|||
SET @s = ( SELECT IF(
|
||||
(SELECT COUNT(*) FROM MontageLayouts WHERE Name='4 Wide') > 0,
|
||||
"SELECT '4 Wide already in layouts'",
|
||||
"INSERT INTO MontageLayouts (`Name`,`Positions`) VALUES ('4 Wide', '{ "default":{"float":"left", "width":"24.5%"} }' );"
|
||||
'INSERT INTO MontageLayouts (`Name`,`Positions`) VALUES (\'4 Wide\', \'{"default":{"float":"left","position":"relative","width":"24.5%","left":"0px","right":"0px","top":"0px","bottom":"0px"}}\');'
|
||||
) );
|
||||
|
||||
PREPARE stmt FROM @s;
|
||||
EXECUTE stmt;
|
||||
|
||||
SET @s = ( SELECT IF(
|
||||
(SELECT COUNT(*) FROM MontageLayouts WHERE Name='5 Wide') > 0,
|
||||
"SELECT '5 Wide already in layouts'",
|
||||
"INSERT INTO MontageLayouts (`Name`,`Positions`) VALUES ('5 Wide', '{ "default":{"float":"left", "width":"19%"} }' );"
|
||||
'INSERT INTO MontageLayouts (`Name`,`Positions`) VALUES (\'5 Wide\', \'{"default":{"float":"left","position":"relative","width":"19%"}}\' );'
|
||||
) );
|
||||
|
||||
PREPARE stmt FROM @s;
|
||||
|
|
|
@ -205,6 +205,30 @@ sub zmDbGetMonitorAndControl {
|
|||
return( $monitor );
|
||||
}
|
||||
|
||||
sub start_transaction {
|
||||
#my ( $caller, undef, $line ) = caller;
|
||||
#$openprint::log->debug("Called start_transaction from $caller : $line");
|
||||
my $d = shift;
|
||||
$d = $dbh if ! $d;
|
||||
my $ac = $d->{AutoCommit};
|
||||
$d->{AutoCommit} = 0;
|
||||
return $ac;
|
||||
} # end sub start_transaction
|
||||
|
||||
sub end_transaction {
|
||||
#my ( $caller, undef, $line ) = caller;
|
||||
#$openprint::log->debug("Called end_transaction from $caller : $line");
|
||||
my ( $d, $ac ) = @_;
|
||||
if ( ! defined $ac ) {
|
||||
Error("Undefined ac");
|
||||
}
|
||||
$d = $dbh if ! $d;
|
||||
if ( $ac ) {
|
||||
#$log->debug("Committing");
|
||||
$d->commit();
|
||||
} # end if
|
||||
$d->{AutoCommit} = $ac;
|
||||
} # end sub end_transaction
|
||||
1;
|
||||
__END__
|
||||
# Below is stub documentation for your module. You'd better edit it!
|
||||
|
|
|
@ -48,9 +48,38 @@ use ZoneMinder::Logger qw(:all);
|
|||
use ZoneMinder::Database qw(:all);
|
||||
require Date::Parse;
|
||||
|
||||
use vars qw/ $table $primary_key /;
|
||||
use vars qw/ $table $primary_key %fields $serial @identified_by/;
|
||||
$table = 'Events';
|
||||
$primary_key = 'Id';
|
||||
@identified_by = ('Id');
|
||||
$serial = $primary_key = 'Id';
|
||||
%fields = map { $_, $_ } qw(
|
||||
Id
|
||||
MonitorId
|
||||
StorageId
|
||||
Name
|
||||
Cause
|
||||
StartTime
|
||||
EndTime
|
||||
Width
|
||||
Height
|
||||
Length
|
||||
Frames
|
||||
AlarmFrames
|
||||
DefaultVideo
|
||||
TotScore
|
||||
AvgScore
|
||||
MaxScore
|
||||
Archived
|
||||
Videoed
|
||||
Uploaded
|
||||
Emailed
|
||||
Messaged
|
||||
Executed
|
||||
Notes
|
||||
StateId
|
||||
Orientation
|
||||
DiskSpace
|
||||
);
|
||||
|
||||
use POSIX;
|
||||
|
||||
|
|
|
@ -678,6 +678,11 @@ sub Dump {
|
|||
fetch()->logPrint( DEBUG, Data::Dumper->Dump( [ $var ], [ $label ] ) );
|
||||
}
|
||||
|
||||
sub debug {
|
||||
my $log = shift;
|
||||
$log->logPrint( DEBUG, @_ );
|
||||
}
|
||||
|
||||
sub Debug( @ ) {
|
||||
fetch()->logPrint( DEBUG, @_ );
|
||||
}
|
||||
|
@ -685,14 +690,27 @@ sub Debug( @ ) {
|
|||
sub Info( @ ) {
|
||||
fetch()->logPrint( INFO, @_ );
|
||||
}
|
||||
sub info {
|
||||
my $log = shift;
|
||||
$log->logPrint( INFO, @_ );
|
||||
}
|
||||
|
||||
|
||||
sub Warning( @ ) {
|
||||
fetch()->logPrint( WARNING, @_ );
|
||||
}
|
||||
sub warn {
|
||||
my $log = shift;
|
||||
$log->logPrint( WARNING, @_ );
|
||||
}
|
||||
|
||||
sub Error( @ ) {
|
||||
fetch()->logPrint( ERROR, @_ );
|
||||
}
|
||||
sub error {
|
||||
my $log = shift;
|
||||
$log->logPrint( ERROR, @_ );
|
||||
}
|
||||
|
||||
sub Fatal( @ ) {
|
||||
fetch()->logPrint( FATAL, @_ );
|
||||
|
|
|
@ -42,7 +42,13 @@ use ZoneMinder::Config qw(:all);
|
|||
use ZoneMinder::Logger qw(:all);
|
||||
use ZoneMinder::Database qw(:all);
|
||||
|
||||
use vars qw/ $AUTOLOAD /;
|
||||
use vars qw/ $AUTOLOAD $log $dbh/;
|
||||
|
||||
*log = \$ZoneMinder::Logger::logger;
|
||||
*dbh = \$ZoneMinder::Database::dbh;
|
||||
|
||||
my $debug = 1;
|
||||
use constant DEBUG_ALL=>1;
|
||||
|
||||
sub new {
|
||||
my ( $parent, $id, $data ) = @_;
|
||||
|
@ -110,7 +116,282 @@ sub AUTOLOAD {
|
|||
return $_[0]{$name};
|
||||
}
|
||||
|
||||
sub save {
|
||||
my ( $self, $data, $force_insert ) = @_;
|
||||
|
||||
my $type = ref $self;
|
||||
if ( ! $type ) {
|
||||
my ( $caller, undef, $line ) = caller;
|
||||
$log->error("No type in Object::save. self:$self from $caller:$line");
|
||||
}
|
||||
my $local_dbh = eval '$'.$type.'::dbh';
|
||||
$local_dbh = $ZoneMinder::Database::dbh if ! $local_dbh;
|
||||
$self->set( $data ? $data : {} );
|
||||
if ( $debug or DEBUG_ALL ) {
|
||||
if ( $data ) {
|
||||
foreach my $k ( keys %$data ) {
|
||||
$log->debug("Object::save after set $k => $$data{$k} $$self{$k}");
|
||||
}
|
||||
} else {
|
||||
$log->debug("No data after set");
|
||||
}
|
||||
}
|
||||
#$debug = 0;
|
||||
|
||||
my $table = eval '$'.$type.'::table';
|
||||
my $fields = eval '\%'.$type.'::fields';
|
||||
my $debug = eval '$'.$type.'::debug';
|
||||
#$debug = DEBUG_ALL if ! $debug;
|
||||
|
||||
my %sql;
|
||||
foreach my $k ( keys %$fields ) {
|
||||
$sql{$$fields{$k}} = $$self{$k} if defined $$fields{$k};
|
||||
} # end foreach
|
||||
if ( ! $force_insert ) {
|
||||
$sql{$$fields{updated_on}} = 'NOW()' if exists $$fields{updated_on};
|
||||
} # end if
|
||||
my $serial = eval '$'.$type.'::serial';
|
||||
my @identified_by = eval '@'.$type.'::identified_by';
|
||||
|
||||
my $ac = ZoneMinder::Database::start_transaction( $local_dbh );
|
||||
if ( ! $serial ) {
|
||||
my $insert = $force_insert;
|
||||
my %serial = eval '%'.$type.'::serial';
|
||||
if ( ! %serial ) {
|
||||
$log->debug("No serial") if $debug;
|
||||
# No serial columns defined, which means that we will do saving by delete/insert instead of insert/update
|
||||
if ( @identified_by ) {
|
||||
my $where = join(' AND ', map { $$fields{$_}.'=?' } @identified_by );
|
||||
if ( $debug ) {
|
||||
$log->debug("DELETE FROM $table WHERE $where");
|
||||
} # end if
|
||||
|
||||
if ( ! ( ( $_ = $local_dbh->prepare("DELETE FROM $table WHERE $where") ) and $_->execute( @$self{@identified_by} ) ) ) {
|
||||
$where =~ s/\?/\%s/g;
|
||||
$log->error("Error deleting: DELETE FROM $table WHERE " . sprintf($where, map { defined $_ ? $_ : 'undef' } ( @$self{@identified_by}) ).'):' . $local_dbh->errstr);
|
||||
$local_dbh->rollback();
|
||||
ZoneMinder::Database::end_transaction( $local_dbh, $ac );
|
||||
return $local_dbh->errstr;
|
||||
} elsif ( $debug ) {
|
||||
$log->debug("SQL succesful DELETE FROM $table WHERE $where");
|
||||
} # end if
|
||||
} # end if
|
||||
$insert = 1;
|
||||
} else {
|
||||
foreach my $id ( @identified_by ) {
|
||||
if ( ! $serial{$id} ) {
|
||||
my ( $caller, undef, $line ) = caller;
|
||||
$log->error("$id nor in serial for $type from $caller:$line") if $debug;
|
||||
next;
|
||||
}
|
||||
if ( ! $$self{$id} ) {
|
||||
my $s = qq{SELECT `auto_increment` FROM INFORMATION_SCHEMA.TABLES WHERE table_name = '$table'};
|
||||
|
||||
($$self{$id}) = ($sql{$$fields{$id}}) = $local_dbh->selectrow_array( $s );
|
||||
#($$self{$id}) = ($sql{$$fields{$id}}) = $local_dbh->selectrow_array( q{SELECT nextval('} . $serial{$id} . q{')} );
|
||||
$log->debug("SQL statement execution SELECT $s returned $$self{$id}") if $debug or DEBUG_ALL;
|
||||
$insert = 1;
|
||||
} # end if
|
||||
} # end foreach
|
||||
} # end if ! %serial
|
||||
|
||||
if ( $insert ) {
|
||||
my @keys = keys %sql;
|
||||
my $command = "INSERT INTO $table (" . join(',', @keys ) . ') VALUES (' . join(',', map { '?' } @sql{@keys} ) . ')';
|
||||
if ( ! ( ( $_ = $local_dbh->prepare($command) ) and $_->execute( @sql{@keys} ) ) ) {
|
||||
my $error = $local_dbh->errstr;
|
||||
$command =~ s/\?/\%s/g;
|
||||
$log->error('SQL statement execution failed: ('.sprintf($command, , map { defined $_ ? $_ : 'undef' } ( @sql{@keys}) ).'):' . $local_dbh->errstr);
|
||||
$local_dbh->rollback();
|
||||
ZoneMinder::Database::end_transaction( $local_dbh, $ac );
|
||||
return $error;
|
||||
} # end if
|
||||
if ( $debug or DEBUG_ALL ) {
|
||||
$command =~ s/\?/\%s/g;
|
||||
$log->debug('SQL statement execution: ('.sprintf($command, , map { defined $_ ? $_ : 'undef' } ( @sql{@keys} ) ).'):' );
|
||||
} # end if
|
||||
} else {
|
||||
my @keys = keys %sql;
|
||||
my $command = "UPDATE $table SET " . join(',', map { $_ . ' = ?' } @keys ) . ' WHERE ' . join(' AND ', map { $_ . ' = ?' } @$fields{@identified_by} );
|
||||
if ( ! ( $_ = $local_dbh->prepare($command) and $_->execute( @sql{@keys,@$fields{@identified_by}} ) ) ) {
|
||||
my $error = $local_dbh->errstr;
|
||||
$command =~ s/\?/\%s/g;
|
||||
$log->error('SQL failed: ('.sprintf($command, , map { defined $_ ? $_ : 'undef' } ( @sql{@keys, @$fields{@identified_by}}) ).'):' . $local_dbh->errstr);
|
||||
$local_dbh->rollback();
|
||||
ZoneMinder::Database::end_transaction( $local_dbh, $ac );
|
||||
return $error;
|
||||
} # end if
|
||||
if ( $debug or DEBUG_ALL ) {
|
||||
$command =~ s/\?/\%s/g;
|
||||
$log->debug('SQL DEBUG: ('.sprintf($command, map { defined $_ ? $_ : 'undef' } ( @sql{@keys,@$fields{@identified_by}} ) ).'):' );
|
||||
} # end if
|
||||
} # end if
|
||||
} else { # not identified_by
|
||||
@identified_by = ('Id') if ! @identified_by;
|
||||
|
||||
# If the size of the arrays are not equal which means one or more are missing
|
||||
my @identified_by_without_values = map { $$self{$_} ? () : $_ } @identified_by;
|
||||
my $need_serial = @identified_by_without_values > 0;
|
||||
|
||||
if ( $force_insert or $need_serial ) {
|
||||
|
||||
if ( $need_serial ) {
|
||||
if ( $serial ) {
|
||||
my $s = qq{SELECT `auto_increment` FROM INFORMATION_SCHEMA.TABLES WHERE table_name = '$table'};
|
||||
@$self{@identified_by} = @sql{@$fields{@identified_by}} = $local_dbh->selectrow_array( $s );
|
||||
#@$self{@identified_by} = @sql{@$fields{@identified_by}} = $local_dbh->selectrow_array( q{SELECT nextval('} . $serial . q{')} );
|
||||
if ( $local_dbh->errstr() ) {
|
||||
$log->error("Error getting next id. " . $local_dbh->errstr() );
|
||||
$log->error("SQL statement execution $s returned ".join(',',@$self{@identified_by}));
|
||||
} elsif ( $debug or DEBUG_ALL ) {
|
||||
$log->debug("SQL statement execution $s returned ".join(',',@$self{@identified_by}));
|
||||
} # end if
|
||||
} # end if
|
||||
} # end if
|
||||
|
||||
my @keys = keys %sql;
|
||||
my $command = "INSERT INTO $table (" . join(',', @keys ) . ') VALUES (' . join(',', map { '?' } @sql{@keys} ) . ')';
|
||||
if ( ! ( $_ = $local_dbh->prepare($command) and $_->execute( @sql{@keys} ) ) ) {
|
||||
$command =~ s/\?/\%s/g;
|
||||
my $error = $local_dbh->errstr;
|
||||
$log->error('SQL failed: ('.sprintf($command, map { defined $_ ? $_ : 'undef' } ( @sql{@keys}) ).'):' . $error);
|
||||
$local_dbh->rollback();
|
||||
ZoneMinder::Database::end_transaction( $local_dbh, $ac );
|
||||
return $error;
|
||||
} # end if
|
||||
if ( $debug or DEBUG_ALL ) {
|
||||
$command =~ s/\?/\%s/g;
|
||||
$log->debug('SQL DEBUG: ('.sprintf($command, map { defined $_ ? $_ : 'undef' } ( @sql{@keys} ) ).'):' );
|
||||
} # end if
|
||||
} else {
|
||||
delete $sql{created_on};
|
||||
my @keys = keys %sql;
|
||||
my %identified_by = map { $_, $_ } @identified_by;
|
||||
|
||||
@keys = map { $identified_by{$_} ? () : $$fields{$_} } @keys;
|
||||
my $command = "UPDATE $table SET " . join(',', map { $_ . ' = ?' } @keys ) . ' WHERE ' . join(' AND ', map { $$fields{$_} .'= ?' } @identified_by );
|
||||
if ( ! ( $_ = $local_dbh->prepare($command) and $_->execute( @sql{@keys}, @sql{@$fields{@identified_by}} ) ) ) {
|
||||
my $error = $local_dbh->errstr;
|
||||
$command =~ s/\?/\%s/g;
|
||||
$log->error('SQL failed: ('.sprintf($command, map { defined $_ ? $_ : 'undef' } ( @sql{@keys}, @sql{@$fields{@identified_by}} ) ).'):' . $error) if $log;
|
||||
$local_dbh->rollback();
|
||||
ZoneMinder::Database::end_transaction( $local_dbh, $ac );
|
||||
return $error;
|
||||
} # end if
|
||||
if ( $debug or DEBUG_ALL ) {
|
||||
$command =~ s/\?/\%s/g;
|
||||
$log->debug('SQL DEBUG: ('.sprintf($command, map { defined $_ ? ( ref $_ eq 'ARRAY' ? join(',',@{$_}) : $_ ) : 'undef' } ( @sql{@keys}, @$self{@identified_by} ) ).'):' );
|
||||
} # end if
|
||||
} # end if
|
||||
} # end if
|
||||
ZoneMinder::Database::end_transaction( $local_dbh, $ac );
|
||||
$self->load();
|
||||
#if ( $$fields{id} ) {
|
||||
#if ( ! $ZoneMinder::Object::cache{$type}{$$self{id}} ) {
|
||||
#$ZoneMinder::Object::cache{$type}{$$self{id}} = $self;
|
||||
#} # end if
|
||||
#delete $ZoneMinder::Object::cache{$config{db_name}}{$type}{$$self{id}};
|
||||
#} # end if
|
||||
#$log->debug("after delete");
|
||||
#eval 'if ( %'.$type.'::find_cache ) { %'.$type.'::find_cache = (); }';
|
||||
#$log->debug("after clear cache");
|
||||
return '';
|
||||
} # end sub save
|
||||
|
||||
sub set {
|
||||
my ( $self, $params ) = @_;
|
||||
my @set_fields = ();
|
||||
|
||||
my $type = ref $self;
|
||||
my %fields = eval ('%'.$type.'::fields');
|
||||
if ( ! %fields ) {
|
||||
$log->warn("ZoneMinder::Object::set called on an object ($type) with no fields".$@);
|
||||
} # end if
|
||||
my %defaults = eval('%'.$type.'::defaults');
|
||||
if ( ref $params ne 'HASH' ) {
|
||||
my ( $caller, undef, $line ) = caller;
|
||||
$log->error("$type -> set called with non-hash params from $caller $line");
|
||||
}
|
||||
|
||||
foreach my $field ( keys %fields ) {
|
||||
if ( $params ) {
|
||||
$log->debug("field: $field, param: ".$$params{$field}) if $debug;
|
||||
if ( exists $$params{$field} ) {
|
||||
$log->debug("field: $field, $$self{$field} =? param: ".$$params{$field}) if $debug;
|
||||
if ( ( ! defined $$self{$field} ) or ($$self{$field} ne $params->{$field}) ) {
|
||||
# Only make changes to fields that have changed
|
||||
if ( defined $fields{$field} ) {
|
||||
$$self{$field} = $$params{$field} if defined $fields{$field};
|
||||
push @set_fields, $fields{$field}, $$params{$field}; #mark for sql updating
|
||||
} # end if
|
||||
$log->debug("Running $field with $$params{$field}") if $debug;
|
||||
if ( my $func = $self->can( $field ) ) {
|
||||
$func->( $self, $$params{$field} );
|
||||
} # end if
|
||||
} # end if
|
||||
} # end if
|
||||
} # end if $params
|
||||
|
||||
if ( defined $fields{$field} ) {
|
||||
if ( $$self{$field} ) {
|
||||
$$self{$field} = transform( $type, $field, $$self{$field} );
|
||||
} # end if $$self{field}
|
||||
}
|
||||
} # end foreach field
|
||||
|
||||
foreach my $field ( keys %defaults ) {
|
||||
|
||||
if ( ( ! exists $$self{$field} ) or (!defined $$self{$field}) or ( $$self{$field} eq '' ) ) {
|
||||
$log->debug("Setting default ($field) ($$self{$field}) ($defaults{$field}) ") if $debug;
|
||||
if ( defined $defaults{$field} ) {
|
||||
$log->debug("Default $field is defined: $defaults{$field}") if $debug;
|
||||
if ( $defaults{$field} eq 'NOW()' ) {
|
||||
$$self{$field} = 'NOW()';
|
||||
} else {
|
||||
$$self{$field} = eval($defaults{$field});
|
||||
$log->error( "Eval error of object default $field default ($defaults{$field}) Reason: " . $@ ) if $@;
|
||||
} # end if
|
||||
} else {
|
||||
$$self{$field} = $defaults{$field};
|
||||
} # end if
|
||||
#$$self{$field} = ( defined $defaults{$field} ) ? eval($defaults{$field}) : $defaults{$field};
|
||||
$log->debug("Setting default for ($field) using ($defaults{$field}) to ($$self{$field}) ") if $debug;
|
||||
} # end if
|
||||
} # end foreach default
|
||||
return @set_fields;
|
||||
} # end sub set
|
||||
|
||||
sub transform {
|
||||
my $type = ref $_[0];
|
||||
$type = $_[0] if ! $type;
|
||||
my $fields = eval '\%'.$type.'::fields';
|
||||
my $value = $_[2];
|
||||
|
||||
if ( defined $$fields{$_[1]} ) {
|
||||
my @transforms = eval('@{$'.$type.'::transforms{$_[1]}}');
|
||||
$log->debug("Transforms for $_[1] before $_[2]: @transforms") if $debug;
|
||||
if ( @transforms ) {
|
||||
foreach my $transform ( @transforms ) {
|
||||
if ( $transform =~ /^s\// or $transform =~ /^tr\// ) {
|
||||
eval '$value =~ ' . $transform;
|
||||
} elsif ( $transform =~ /^<(\d+)/ ) {
|
||||
if ( $value > $1 ) {
|
||||
$value = undef;
|
||||
} # end if
|
||||
} else {
|
||||
$log->debug("evalling $value ".$transform . " Now value is $value" );
|
||||
eval '$value '.$transform;
|
||||
$log->error("Eval error $@") if $@;
|
||||
}
|
||||
$log->debug("After $transform: $value") if $debug;
|
||||
} # end foreach
|
||||
} # end if
|
||||
} else {
|
||||
$log->error("Object::transform ($_[1]) not in fields for $type");
|
||||
} # end if
|
||||
return $value;
|
||||
|
||||
} # end sub transform
|
||||
1;
|
||||
__END__
|
||||
|
||||
|
|
|
@ -270,7 +270,7 @@ void MonitorStream::processCommand( const CmdMsg *msg ) {
|
|||
Debug( 1, "Got SCALE command, to %d", scale );
|
||||
break;
|
||||
}
|
||||
case CMD_QUIT :
|
||||
case CMD_QUIT :
|
||||
{
|
||||
Info ("User initiated exit - CMD_QUIT");
|
||||
break;
|
||||
|
@ -316,7 +316,7 @@ void MonitorStream::processCommand( const CmdMsg *msg ) {
|
|||
//status_data.enabled = monitor->shared_data->active;
|
||||
status_data.enabled = monitor->trigger_data->trigger_state!=Monitor::TRIGGER_OFF;
|
||||
status_data.forced = monitor->trigger_data->trigger_state==Monitor::TRIGGER_ON;
|
||||
Debug( 2, "L:%d, D:%d, P:%d, R:%d, d:%.3f, Z:%d, E:%d F:%d",
|
||||
Debug( 2, "Buffer Level:%d, Delayed:%d, Paused:%d, Rate:%d, delay:%.3f, Zoom:%d, Enabled:%d Forced:%d",
|
||||
status_data.buffer_level,
|
||||
status_data.delayed,
|
||||
status_data.paused,
|
||||
|
@ -338,11 +338,15 @@ void MonitorStream::processCommand( const CmdMsg *msg ) {
|
|||
//exit( -1 );
|
||||
}
|
||||
}
|
||||
Debug(2, "NUmber of bytes sent: (%d)", nbytes );
|
||||
|
||||
// quit after sending a status, if this was a quit request
|
||||
if ((MsgCommand)msg->msg_data[0]==CMD_QUIT)
|
||||
exit(0);
|
||||
if ( (MsgCommand)msg->msg_data[0]==CMD_QUIT ) {
|
||||
Debug(2,"Quitting");
|
||||
exit(0);
|
||||
}
|
||||
|
||||
Debug(2,"Updating framrate");
|
||||
updateFrameRate( monitor->GetFPS() );
|
||||
} // end void MonitorStream::processCommand( const CmdMsg *msg )
|
||||
|
||||
|
@ -565,7 +569,7 @@ void MonitorStream::runStream() {
|
|||
gettimeofday( &now, NULL );
|
||||
|
||||
if ( connkey ) {
|
||||
Debug(2, "checking command Queue");
|
||||
Debug(2, "checking command Queue for connkey: %d", connkey );
|
||||
while(checkCommandQueue()) {
|
||||
got_command = true;
|
||||
}
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
<?php
|
||||
|
||||
$start_time = time();
|
||||
|
||||
define( "MSG_TIMEOUT", ZM_WEB_AJAX_TIMEOUT );
|
||||
define( "MSG_DATA_SIZE", 4+256 );
|
||||
|
||||
|
@ -11,40 +13,49 @@ if ( !($socket = @socket_create( AF_UNIX, SOCK_DGRAM, 0 )) ) {
|
|||
ajaxError( "socket_create() failed: ".socket_strerror(socket_last_error()) );
|
||||
}
|
||||
$locSockFile = ZM_PATH_SOCKS.'/zms-'.sprintf("%06d",$_REQUEST['connkey']).'w.sock';
|
||||
if ( file_exists( $locSockFile ) ) {
|
||||
Warning("sock file $locSockFile already exists?! Is someone else talking to zms?");
|
||||
} else {
|
||||
Logger::Debug("socket file does not exist, we should be good to connect.");
|
||||
}
|
||||
if ( !@socket_bind( $socket, $locSockFile ) ) {
|
||||
ajaxError( "socket_bind( $locSockFile ) failed: ".socket_strerror(socket_last_error()) );
|
||||
} else {
|
||||
Logger::Debug("Bound to $locSockFile");
|
||||
}
|
||||
|
||||
switch ( $_REQUEST['command'] ) {
|
||||
case CMD_VARPLAY :
|
||||
Logger::Debug( "Varplaying to ".$_REQUEST['rate'] );
|
||||
$msg = pack( "lcn", MSG_CMD, $_REQUEST['command'], $_REQUEST['rate']+32768 );
|
||||
Logger::Debug( 'Varplaying to '.$_REQUEST['rate'] );
|
||||
$msg = pack( 'lcn', MSG_CMD, $_REQUEST['command'], $_REQUEST['rate']+32768 );
|
||||
break;
|
||||
case CMD_ZOOMIN :
|
||||
Logger::Debug( "Zooming to ".$_REQUEST['x'].",".$_REQUEST['y'] );
|
||||
$msg = pack( "lcnn", MSG_CMD, $_REQUEST['command'], $_REQUEST['x'], $_REQUEST['y'] );
|
||||
Logger::Debug( 'Zooming to '.$_REQUEST['x'].",".$_REQUEST['y'] );
|
||||
$msg = pack( 'lcnn', MSG_CMD, $_REQUEST['command'], $_REQUEST['x'], $_REQUEST['y'] );
|
||||
break;
|
||||
case CMD_PAN :
|
||||
Logger::Debug( "Panning to ".$_REQUEST['x'].",".$_REQUEST['y'] );
|
||||
$msg = pack( "lcnn", MSG_CMD, $_REQUEST['command'], $_REQUEST['x'], $_REQUEST['y'] );
|
||||
Logger::Debug( 'Panning to '.$_REQUEST['x'].",".$_REQUEST['y'] );
|
||||
$msg = pack( 'lcnn', MSG_CMD, $_REQUEST['command'], $_REQUEST['x'], $_REQUEST['y'] );
|
||||
break;
|
||||
case CMD_SCALE :
|
||||
Logger::Debug( "Scaling to ".$_REQUEST['scale'] );
|
||||
$msg = pack( "lcn", MSG_CMD, $_REQUEST['command'], $_REQUEST['scale'] );
|
||||
Logger::Debug( 'Scaling to '.$_REQUEST['scale'] );
|
||||
$msg = pack( 'lcn', MSG_CMD, $_REQUEST['command'], $_REQUEST['scale'] );
|
||||
break;
|
||||
case CMD_SEEK :
|
||||
Logger::Debug( "Seeking to ".$_REQUEST['offset'] );
|
||||
$msg = pack( "lcN", MSG_CMD, $_REQUEST['command'], $_REQUEST['offset'] );
|
||||
Logger::Debug( 'Seeking to '.$_REQUEST['offset'] );
|
||||
$msg = pack( 'lcN', MSG_CMD, $_REQUEST['command'], $_REQUEST['offset'] );
|
||||
break;
|
||||
default :
|
||||
$msg = pack( "lc", MSG_CMD, $_REQUEST['command'] );
|
||||
$msg = pack( 'lc', MSG_CMD, $_REQUEST['command'] );
|
||||
break;
|
||||
}
|
||||
|
||||
$remSockFile = ZM_PATH_SOCKS.'/zms-'.sprintf("%06d",$_REQUEST['connkey']).'s.sock';
|
||||
$remSockFile = ZM_PATH_SOCKS.'/zms-'.sprintf('%06d',$_REQUEST['connkey']).'s.sock';
|
||||
$max_socket_tries = 10;
|
||||
// FIXME This should not exceed web_ajax_timeout
|
||||
while ( !file_exists($remSockFile) && $max_socket_tries-- ) { //sometimes we are too fast for our own good, if it hasn't been setup yet give it a second.
|
||||
usleep(2000000);
|
||||
Logger::Debug("$remSockFile does not exist, waiting, current " . (time() - $start_time) . ' seconds' );
|
||||
usleep(200000);
|
||||
}
|
||||
|
||||
if ( !file_exists($remSockFile) ) {
|
||||
|
@ -58,17 +69,26 @@ if ( !file_exists($remSockFile) ) {
|
|||
$rSockets = array( $socket );
|
||||
$wSockets = NULL;
|
||||
$eSockets = NULL;
|
||||
$numSockets = @socket_select( $rSockets, $wSockets, $eSockets, intval(MSG_TIMEOUT/1000), (MSG_TIMEOUT%1000)*1000 );
|
||||
|
||||
$timeout = MSG_TIMEOUT - ( time() - $start_time );
|
||||
Logger::Debug("TImeout is: $timeout " );
|
||||
|
||||
$numSockets = @socket_select( $rSockets, $wSockets, $eSockets, intval($timeout/1000), ($timeout%1000)*1000 );
|
||||
|
||||
if ( $numSockets === false ) {
|
||||
Error("socket_select failed: " . socket_strerror(socket_last_error()) );
|
||||
ajaxError( "socket_select failed: ".socket_strerror(socket_last_error()) );
|
||||
} else if ( $numSockets < 0 ) {
|
||||
Error( "Socket closed $remSockFile" );
|
||||
ajaxError( "Socket closed $remSockFile" );
|
||||
} else if ( $numSockets == 0 ) {
|
||||
Error( "Timed out waiting for msg $remSockFile" );
|
||||
ajaxError( "Timed out waiting for msg $remSockFile" );
|
||||
} else if ( $numSockets > 0 ) {
|
||||
if ( count($rSockets) != 1 )
|
||||
ajaxError( "Bogus return from select, ".count($rSockets)." sockets available" );
|
||||
if ( count($rSockets) != 1 ) {
|
||||
Error( "Bogus return from select, ".count($rSockets).' sockets available' );
|
||||
ajaxError( "Bogus return from select, ".count($rSockets).' sockets available' );
|
||||
}
|
||||
}
|
||||
|
||||
switch( $nbytes = @socket_recvfrom( $socket, $msg, MSG_DATA_SIZE, 0, $remSockFile ) ) {
|
||||
|
@ -79,7 +99,7 @@ switch( $nbytes = @socket_recvfrom( $socket, $msg, MSG_DATA_SIZE, 0, $remSockFil
|
|||
}
|
||||
case 0 :
|
||||
{
|
||||
ajaxError( "No data to read from socket" );
|
||||
ajaxError( 'No data to read from socket' );
|
||||
break;
|
||||
}
|
||||
default :
|
||||
|
@ -90,7 +110,7 @@ switch( $nbytes = @socket_recvfrom( $socket, $msg, MSG_DATA_SIZE, 0, $remSockFil
|
|||
}
|
||||
}
|
||||
|
||||
$data = unpack( "ltype", $msg );
|
||||
$data = unpack( 'ltype', $msg );
|
||||
switch ( $data['type'] ) {
|
||||
case MSG_DATA_WATCH :
|
||||
{
|
||||
|
@ -99,7 +119,7 @@ switch ( $data['type'] ) {
|
|||
$data['rate'] /= RATE_BASE;
|
||||
$data['delay'] = round( $data['delay'], 2 );
|
||||
$data['zoom'] = round( $data['zoom']/SCALE_BASE, 1 );
|
||||
if ( ZM_OPT_USE_AUTH && ZM_AUTH_RELAY == "hashed" ) {
|
||||
if ( ZM_OPT_USE_AUTH && ZM_AUTH_RELAY == 'hashed' ) {
|
||||
session_start();
|
||||
$time = time();
|
||||
// Regenerate auth hash after half the lifetime of the hash
|
||||
|
@ -117,7 +137,7 @@ switch ( $data['type'] ) {
|
|||
//$data['progress'] = sprintf( "%.2f", $data['progress'] );
|
||||
$data['rate'] /= RATE_BASE;
|
||||
$data['zoom'] = round( $data['zoom']/SCALE_BASE, 1 );
|
||||
if ( ZM_OPT_USE_AUTH && ZM_AUTH_RELAY == "hashed" ) {
|
||||
if ( ZM_OPT_USE_AUTH && ZM_AUTH_RELAY == 'hashed' ) {
|
||||
session_start();
|
||||
$time = time();
|
||||
// Regenerate auth hash after half the lifetime of the hash
|
||||
|
|
|
@ -111,11 +111,21 @@ class MontageLayout {
|
|||
$this->{$k} = $v;
|
||||
}
|
||||
}
|
||||
|
||||
$sql = 'UPDATE MontageLayouts SET '.implode(', ', array_map( function($field) {return $field.'=?';}, array_keys( $this->defaults ) ) ) . ' WHERE Id=?';
|
||||
$values = array_map( function($field){return $this->{$field};}, $this->fields );
|
||||
$values[] = $this->{'Id'};
|
||||
|
||||
$fields = array_values( array_filter( array_keys($this->defaults), function($field){return $field != 'Id';} ) );
|
||||
$values = null;
|
||||
if ( isset($this->{'Id'}) ) {
|
||||
$sql = 'UPDATE MontageLayouts SET '.implode(', ', array_map( function($field) {return $field.'=?';}, $fields ) ) . ' WHERE Id=?';
|
||||
$values = array_map( function($field){return $this->{$field};}, $fields );
|
||||
$values[] = $this->{'Id'};
|
||||
dbQuery( $sql, $values );
|
||||
} else {
|
||||
$sql = 'INSERT INTO MontageLayouts ('.implode( ',', $fields ).') VALUES ('.implode(',',array_map( function(){return '?';}, $fields ) ).')';
|
||||
$values = array_map( function($field){return $this->{$field};}, $fields );
|
||||
dbQuery( $sql, $values );
|
||||
global $dbConn;
|
||||
$this->{Id} = $dbConn->lastInsertId();
|
||||
}
|
||||
} // end function save
|
||||
|
||||
} // end class MontageLayout
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -122,15 +122,24 @@ function dbQuery( $sql, $params=NULL ) {
|
|||
$result = NULL;
|
||||
try {
|
||||
if ( isset($params) ) {
|
||||
$result = $dbConn->prepare( $sql );
|
||||
$result->execute( $params );
|
||||
if ( ! $result = $dbConn->prepare( $sql ) ) {
|
||||
Error("SQL: Error preparing $sql: " . $pdo->errorInfo);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if ( ! $result->execute( $params ) ) {
|
||||
Error("SQL: Error executing $sql: " . implode(',', $result->errorInfo() ) );
|
||||
return NULL;
|
||||
}
|
||||
} else {
|
||||
$result = $dbConn->query( $sql );
|
||||
}
|
||||
if ( 0 ) {
|
||||
if ( $params )
|
||||
Warning("SQL: $sql" . implode(',',$params));
|
||||
Warning("SQL: $sql" . implode(',',$params) . ' rows: '.$result->rowCount() );
|
||||
else
|
||||
Warning("SQL: $sql" );
|
||||
Warning("SQL: $sql: rows:" . $result->rowCount() );
|
||||
}
|
||||
} catch(PDOException $e) {
|
||||
Error( "SQL-ERR '".$e->getMessage()."', statement was '".$sql."' params:" . implode(',',$params) );
|
||||
}
|
||||
|
|
|
@ -2060,6 +2060,19 @@ function detaintPath( $path ) {
|
|||
return( $path );
|
||||
}
|
||||
|
||||
function cache_bust( $file ) {
|
||||
# Use the last modified timestamp to create a link that gets a different filename
|
||||
# To defeat caching. Should probably use md5 hash
|
||||
$parts = pathinfo($file);
|
||||
$cacheFile = '/cache/'.$parts['filename'].'-'.filemtime($file).'.'.$parts['extension'];
|
||||
if ( file_exists( ZM_PATH_WEB.$cacheFile ) or symlink( ZM_PATH_WEB.'/'.$file, ZM_PATH_WEB.$cacheFile ) ) {
|
||||
return $cacheFile;
|
||||
} else {
|
||||
Warning("Failed linking $file to $cacheFile");
|
||||
}
|
||||
return $file;
|
||||
}
|
||||
|
||||
function getSkinFile( $file ) {
|
||||
global $skinBase;
|
||||
$skinFile = false;
|
||||
|
@ -2068,7 +2081,7 @@ function getSkinFile( $file ) {
|
|||
if ( file_exists( $tempSkinFile ) )
|
||||
$skinFile = $tempSkinFile;
|
||||
}
|
||||
return( $skinFile );
|
||||
return $skinFile;
|
||||
}
|
||||
|
||||
function getSkinIncludes( $file, $includeBase=false, $asOverride=false ) {
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -113,7 +113,7 @@ if ( !file_exists( ZM_SKIN_PATH ) )
|
|||
$skinBase[] = $skin;
|
||||
|
||||
$currentCookieParams = session_get_cookie_params();
|
||||
Logger::Debug('Setting cookie parameters to lifetime('.$currentCookieParams['lifetime'].') path('.$currentCookieParams['path'].') domain ('.$currentCookieParams['domain'].') secure('.$currentCookieParams['secure'].') httpOnly(1)');
|
||||
//Logger::Debug('Setting cookie parameters to lifetime('.$currentCookieParams['lifetime'].') path('.$currentCookieParams['path'].') domain ('.$currentCookieParams['domain'].') secure('.$currentCookieParams['secure'].') httpOnly(1)');
|
||||
session_set_cookie_params(
|
||||
$currentCookieParams['lifetime'],
|
||||
$currentCookieParams['path'],
|
||||
|
@ -175,9 +175,7 @@ foreach ( getSkinIncludes( 'skin.php' ) as $includeFile )
|
|||
|
||||
if ( ZM_OPT_USE_AUTH && ZM_AUTH_HASH_LOGINS ) {
|
||||
if ( empty($user) && ! empty($_REQUEST['auth']) ) {
|
||||
Logger::Debug("Getting user from auth hash");
|
||||
if ( $authUser = getAuthUser( $_REQUEST['auth'] ) ) {
|
||||
Logger::Debug("Success Getting user from auth hash");
|
||||
userLogin( $authUser['Username'], $authUser['Password'], true );
|
||||
}
|
||||
} else if ( ! empty($user) ) {
|
||||
|
|
|
@ -302,6 +302,7 @@ $SLANG = array(
|
|||
'DuplicateMonitorName' => 'Duplicate Monitor Name',
|
||||
'Duration' => 'Duration',
|
||||
'Edit' => 'Edit',
|
||||
'EditLayout' => 'Edit Layout',
|
||||
'Email' => 'Email',
|
||||
'EnableAlarms' => 'Enable Alarms',
|
||||
'Enabled' => 'Enabled',
|
||||
|
|
|
@ -6,6 +6,15 @@
|
|||
width: 99%;
|
||||
}
|
||||
|
||||
#monitors:after {
|
||||
content: ".";
|
||||
display: block;
|
||||
height: 0;
|
||||
font-size: 0;
|
||||
clear: both;
|
||||
visibility: hidden;
|
||||
}
|
||||
|
||||
#monitors .monitor {
|
||||
min-width: 180px;
|
||||
margin: 0;
|
||||
|
|
|
@ -60,11 +60,11 @@ if ( file_exists( "skins/$skin/css/$css/graphics/favicon.ico" ) ) {
|
|||
<link rel="stylesheet" href="css/reset.css" type="text/css"/>
|
||||
<link rel="stylesheet" href="css/overlay.css" type="text/css"/>
|
||||
<link rel="stylesheet" href="css/bootstrap.min.css" type="text/css"/>
|
||||
<link rel="stylesheet" href="<?php echo $skinCssFile ?>" type="text/css" media="screen"/>
|
||||
<link rel="stylesheet" href="<?php echo cache_bust($skinCssFile) ?>" type="text/css" media="screen"/>
|
||||
<?php
|
||||
if ( $viewCssFile ) {
|
||||
?>
|
||||
<link rel="stylesheet" href="<?php echo $viewCssFile ?>" type="text/css" media="screen"/>
|
||||
<link rel="stylesheet" href="<?php echo cache_bust($viewCssFile) ?>" type="text/css" media="screen"/>
|
||||
<?php
|
||||
}
|
||||
if ( $viewCssPhpFile ) {
|
||||
|
@ -138,18 +138,18 @@ if ( file_exists( "skins/$skin/css/$css/graphics/favicon.ico" ) ) {
|
|||
}
|
||||
if ( $cssJsFile ) {
|
||||
?>
|
||||
<script type="text/javascript" src="<?php echo $cssJsFile ?>"></script>
|
||||
<script type="text/javascript" src="<?php echo cache_bust($cssJsFile) ?>"></script>
|
||||
<?php
|
||||
} else {
|
||||
?>
|
||||
<script type="text/javascript" src="skins/classic/js/classic.js"></script>
|
||||
<?php } ?>
|
||||
<script type="text/javascript" src="<?php echo $skinJsFile ?>"></script>
|
||||
<script type="text/javascript" src="<?php echo cache_bust($skinJsFile) ?>"></script>
|
||||
<script type="text/javascript" src="js/logger.js"></script>
|
||||
<?php
|
||||
if ( $viewJsFile ) {
|
||||
?>
|
||||
<script type="text/javascript" src="<?php echo $viewJsFile ?>"></script>
|
||||
<script type="text/javascript" src="<?php echo cache_bust($viewJsFile) ?>"></script>
|
||||
<?php
|
||||
}
|
||||
?>
|
||||
|
|
|
@ -0,0 +1,150 @@
|
|||
<?php
|
||||
//
|
||||
// ZoneMinder web console file, $Date$, $Revision$
|
||||
// Copyright (C) 2001-2008 Philip Coombes
|
||||
//
|
||||
// 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
//
|
||||
|
||||
$servers = Server::find_all();
|
||||
$ServersById = array();
|
||||
foreach ( $servers as $S ) {
|
||||
$ServersById[$S->Id()] = $S;
|
||||
}
|
||||
session_start();
|
||||
foreach ( array('ServerFilter','StorageFilter','StatusFilter','MonitorId') as $var ) {
|
||||
if ( isset( $_REQUEST[$var] ) ) {
|
||||
if ( $_REQUEST[$var] != '' ) {
|
||||
$_SESSION[$var] = $_REQUEST[$var];
|
||||
} else {
|
||||
unset( $_SESSION[$var] );
|
||||
}
|
||||
} else if ( isset( $_COOKIE[$var] ) ) {
|
||||
if ( $_COOKIE[$var] != '' ) {
|
||||
$_SESSION[$var] = $_COOKIE[$var];
|
||||
} else {
|
||||
unset($_SESSION[$var]);
|
||||
}
|
||||
}
|
||||
}
|
||||
session_write_close();
|
||||
|
||||
$storage_areas = Storage::find_all();
|
||||
$StorageById = array();
|
||||
foreach ( $storage_areas as $S ) {
|
||||
$StorageById[$S->Id()] = $S;
|
||||
}
|
||||
|
||||
?>
|
||||
<div class="controlHeader">
|
||||
<span id="groupControl"><label><?php echo translate('Group') ?>:</label>
|
||||
<?php
|
||||
# This will end up with the group_id of the deepest selection
|
||||
$group_id = Group::get_group_dropdowns();
|
||||
$groupSql = Group::get_group_sql( $group_id );
|
||||
?>
|
||||
</span>
|
||||
<span id="monitorControl"><label><?php echo translate('Monitor') ?>:</label>
|
||||
<?php
|
||||
|
||||
$monitor_id = isset($_SESSION['MonitorId']) ? $_SESSION['MonitorId'] : 0;
|
||||
|
||||
# Used to determine if the Cycle button should be made available
|
||||
|
||||
$conditions = array();
|
||||
$values = array();
|
||||
|
||||
if ( $groupSql )
|
||||
$conditions[] = $groupSql;
|
||||
if ( isset($_SESSION['ServerFilter']) ) {
|
||||
$conditions[] = 'ServerId=?';
|
||||
$values[] = $_SESSION['ServerFilter'];
|
||||
}
|
||||
if ( isset($_SESSION['StorageFilter']) ) {
|
||||
$conditions[] = 'StorageId=?';
|
||||
$values[] = $_SESSION['StorageFilter'];
|
||||
}
|
||||
if ( ! empty( $user['MonitorIds'] ) ) {
|
||||
$ids = explode(',', $user['MonitorIds'] );
|
||||
$conditions[] = 'Id IN ('.implode(',',array_map( function(){return '?';}, $ids) ).')';
|
||||
$values += $ids;
|
||||
}
|
||||
|
||||
$sql = 'SELECT * FROM Monitors' . ( count($conditions) ? ' WHERE ' . implode(' AND ', $conditions ) : '' ).' ORDER BY Sequence ASC';
|
||||
$monitors = dbFetchAll( $sql, null, $values );
|
||||
$displayMonitors = array();
|
||||
$monitors_dropdown = array(''=>'All');
|
||||
|
||||
if ( $monitor_id ) {
|
||||
$found_selected_monitor = false;
|
||||
|
||||
for ( $i = 0; $i < count($monitors); $i++ ) {
|
||||
if ( !visibleMonitor( $monitors[$i]['Id'] ) ) {
|
||||
continue;
|
||||
}
|
||||
$monitors_dropdown[$monitors[$i]['Id']] = $monitors[$i]['Name'];
|
||||
if ( $monitors[$i]['Id'] == $monitor_id ) {
|
||||
$found_selected_monitor = true;
|
||||
}
|
||||
}
|
||||
if ( ! $found_selected_monitor ) {
|
||||
$monitor_id = '';
|
||||
}
|
||||
}
|
||||
for ( $i = 0; $i < count($monitors); $i++ ) {
|
||||
if ( !visibleMonitor( $monitors[$i]['Id'] ) ) {
|
||||
continue;
|
||||
}
|
||||
$monitors_dropdown[$monitors[$i]['Id']] = $monitors[$i]['Name'];
|
||||
|
||||
if ( $monitor_id and ( $monitors[$i]['Id'] != $monitor_id ) ) {
|
||||
continue;
|
||||
}
|
||||
$displayMonitors[] = $monitors[$i];
|
||||
}
|
||||
echo htmlSelect( 'MonitorId', $monitors_dropdown, $monitor_id, array('onchange'=>'changeMonitor(this);') );
|
||||
?>
|
||||
</span>
|
||||
<?php
|
||||
if ( count($ServersById) > 0 ) {
|
||||
?>
|
||||
<span class="ServerFilter"><label><?php echo translate('Server')?>:</label>
|
||||
<?php
|
||||
echo htmlSelect( 'ServerFilter', array(''=>'All')+$ServersById, (isset($_SESSION['ServerFilter'])?$_SESSION['ServerFilter']:''), array('onchange'=>'changeFilter(this);') );
|
||||
?>
|
||||
</span>
|
||||
<?php
|
||||
}
|
||||
if ( count($StorageById) > 0 ) { ?>
|
||||
<span class="StorageFilter"><label><?php echo translate('Storage')?>:</label>
|
||||
<?php
|
||||
echo htmlSelect( 'StorageFilter', array(''=>'All')+$StorageById, (isset($_SESSION['StorageFilter'])?$_SESSION['StorageFilter']:''), array('onchange'=>'changeFilter(this);') );
|
||||
?>
|
||||
</span>
|
||||
<?php
|
||||
}
|
||||
?>
|
||||
<span class="StatusFilter"><label><?php echo translate('Status')?>:</label>
|
||||
<?php
|
||||
$status_options = array(
|
||||
''=>'All',
|
||||
'Unknown' => translate('Unknown'),
|
||||
'NotRunning' => translate('NotRunning'),
|
||||
'Running' => translate('Running'),
|
||||
);
|
||||
echo htmlSelect( 'StatusFilter', $status_options, ( isset($_SESSION['StatusFilter']) ? $_SESSION['StatusFilter'] : '' ), array('onchange'=>'changeFilter(this);') );
|
||||
?>
|
||||
</span>
|
||||
</div>
|
|
@ -18,36 +18,6 @@
|
|||
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
//
|
||||
|
||||
$servers = Server::find_all();
|
||||
$ServersById = array();
|
||||
foreach ( $servers as $S ) {
|
||||
$ServersById[$S->Id()] = $S;
|
||||
}
|
||||
session_start();
|
||||
foreach ( array('ServerFilter','StorageFilter') as $var ) {
|
||||
if ( isset( $_REQUEST[$var] ) ) {
|
||||
if ( $_REQUEST[$var] != '' ) {
|
||||
$_SESSION[$var] = $_REQUEST[$var];
|
||||
} else {
|
||||
unset( $_SESSION[$var] );
|
||||
}
|
||||
} else if ( isset( $_COOKIE[$var] ) ) {
|
||||
if ( $_COOKIE[$var] != '' ) {
|
||||
$_SESSION[$var] = $_COOKIE[$var];
|
||||
} else {
|
||||
unset($_SESSION[$var]);
|
||||
}
|
||||
}
|
||||
}
|
||||
session_write_close();
|
||||
|
||||
$storage_areas = Storage::find_all();
|
||||
$StorageById = array();
|
||||
foreach ( $storage_areas as $S ) {
|
||||
$StorageById[$S->Id()] = $S;
|
||||
}
|
||||
|
||||
$show_storage_areas = count($storage_areas) > 1 and canEdit( 'System' ) ? 1 : 0;
|
||||
if ( $running == null )
|
||||
$running = daemonCheck();
|
||||
|
||||
|
@ -120,6 +90,45 @@ $eventCounts = array(
|
|||
|
||||
|
||||
$navbar = getNavBarHTML();
|
||||
ob_start();
|
||||
include('_monitor_filters.php');
|
||||
$filterbar = ob_get_contents();
|
||||
ob_end_clean();
|
||||
|
||||
$show_storage_areas = count($storage_areas) > 1 and canEdit( 'System' ) ? 1 : 0;
|
||||
$maxWidth = 0;
|
||||
$maxHeight = 0;
|
||||
$zoneCount = 0;
|
||||
for ( $i = 0; $i < count($displayMonitors); $i++ ) {
|
||||
$monitor = &$displayMonitors[$i];
|
||||
if ( $monitor['Function'] != 'None' ) {
|
||||
$scaleWidth = reScale( $monitor['Width'], $monitor['DefaultScale'], ZM_WEB_DEFAULT_SCALE );
|
||||
$scaleHeight = reScale( $monitor['Height'], $monitor['DefaultScale'], ZM_WEB_DEFAULT_SCALE );
|
||||
if ( $maxWidth < $scaleWidth ) $maxWidth = $scaleWidth;
|
||||
if ( $maxHeight < $scaleHeight ) $maxHeight = $scaleHeight;
|
||||
}
|
||||
$monitor['zmc'] = zmcStatus( $monitor );
|
||||
$monitor['zma'] = zmaStatus( $monitor );
|
||||
$monitor['ZoneCount'] = dbFetchOne( 'select count(Id) as ZoneCount from Zones where MonitorId = ?', 'ZoneCount', array($monitor['Id']) );
|
||||
$zoneCount += $monitor['ZoneCount'];
|
||||
|
||||
$counts = array();
|
||||
for ( $j = 0; $j < count($eventCounts); $j += 1 ) {
|
||||
$filter = addFilterTerm( $eventCounts[$j]['filter'], count($eventCounts[$j]['filter']['Query']['terms']), array( 'cnj' => 'and', 'attr' => 'MonitorId', 'op' => '=', 'val' => $monitor['Id'] ) );
|
||||
parseFilter( $filter );
|
||||
$counts[] = 'count(if(1'.$filter['sql'].",1,NULL)) AS EventCount$j, SUM(if(1".$filter['sql'].",DiskSpace,NULL)) As DiskSpace$j";
|
||||
$monitor['eventCounts'][$j]['filter'] = $filter;
|
||||
}
|
||||
$sql = 'SELECT '.join($counts,', ').' FROM Events as E where MonitorId = ?';
|
||||
$counts = dbFetchOne( $sql, NULL, array($monitor['Id']) );
|
||||
if ( $counts )
|
||||
$displayMonitors[$i] = $monitor = array_merge( $monitor, $counts );
|
||||
for ( $j = 0; $j < count($eventCounts); $j += 1 ) {
|
||||
$eventCounts[$j]['total'] += $monitor['EventCount'.$j];
|
||||
}
|
||||
}
|
||||
$cycleWidth = $maxWidth;
|
||||
$cycleHeight = $maxHeight;
|
||||
|
||||
noCacheHeaders();
|
||||
|
||||
|
@ -137,139 +146,7 @@ xhtmlHeaders( __FILE__, translate('Console') );
|
|||
<input type="hidden" name="action" value=""/>
|
||||
|
||||
<?php echo $navbar ?>
|
||||
<div class="controlHeader">
|
||||
<span id="groupControl"><label><?php echo translate('Group') ?>:</label>
|
||||
<?php
|
||||
# This will end up with the group_id of the deepest selection
|
||||
$group_id = Group::get_group_dropdowns();
|
||||
$groupSql = Group::get_group_sql( $group_id );
|
||||
?>
|
||||
</span>
|
||||
<span id="monitorControl"><label><?php echo translate('Monitor') ?>:</label>
|
||||
<?php
|
||||
|
||||
$monitor_id = 0;
|
||||
if ( isset( $_REQUEST['monitor_id'] ) ) {
|
||||
$monitor_id = $_REQUEST['monitor_id'];
|
||||
} else if ( isset($_COOKIE['zmMonitorId']) ) {
|
||||
$monitor_id = $_COOKIE['zmMonitorId'];
|
||||
}
|
||||
|
||||
$maxWidth = 0;
|
||||
$maxHeight = 0;
|
||||
# Used to determine if the Cycle button should be made available
|
||||
|
||||
$conditions = array();
|
||||
$values = array();
|
||||
|
||||
if ( $groupSql )
|
||||
$conditions[] = $groupSql;
|
||||
if ( isset($_SESSION['ServerFilter']) ) {
|
||||
$conditions[] = 'ServerId=?';
|
||||
$values[] = $_SESSION['ServerFilter'];
|
||||
}
|
||||
if ( isset($_SESSION['StorageFilter']) ) {
|
||||
$conditions[] = 'StorageId=?';
|
||||
$values[] = $_SESSION['StorageFilter'];
|
||||
}
|
||||
$sql = 'SELECT * FROM Monitors' . ( count($conditions) ? ' WHERE ' . implode(' AND ', $conditions ) : '' ).' ORDER BY Sequence ASC';
|
||||
$monitors = dbFetchAll( $sql, null, $values );
|
||||
$displayMonitors = array();
|
||||
$monitors_dropdown = array(''=>'All');
|
||||
|
||||
if ( $monitor_id ) {
|
||||
$found_selected_monitor = false;
|
||||
|
||||
for ( $i = 0; $i < count($monitors); $i++ ) {
|
||||
if ( !visibleMonitor( $monitors[$i]['Id'] ) ) {
|
||||
continue;
|
||||
}
|
||||
$monitors_dropdown[$monitors[$i]['Id']] = $monitors[$i]['Name'];
|
||||
if ( $monitors[$i]['Id'] == $monitor_id ) {
|
||||
$found_selected_monitor = true;
|
||||
}
|
||||
}
|
||||
if ( ! $found_selected_monitor ) {
|
||||
$monitor_id = '';
|
||||
}
|
||||
}
|
||||
for ( $i = 0; $i < count($monitors); $i++ ) {
|
||||
if ( !visibleMonitor( $monitors[$i]['Id'] ) ) {
|
||||
continue;
|
||||
}
|
||||
$monitors_dropdown[$monitors[$i]['Id']] = $monitors[$i]['Name'];
|
||||
|
||||
if ( $monitor_id and ( $monitors[$i]['Id'] != $monitor_id ) ) {
|
||||
continue;
|
||||
}
|
||||
if ( $monitors[$i]['Function'] != 'None' ) {
|
||||
$scaleWidth = reScale( $monitors[$i]['Width'], $monitors[$i]['DefaultScale'], ZM_WEB_DEFAULT_SCALE );
|
||||
$scaleHeight = reScale( $monitors[$i]['Height'], $monitors[$i]['DefaultScale'], ZM_WEB_DEFAULT_SCALE );
|
||||
if ( $maxWidth < $scaleWidth ) $maxWidth = $scaleWidth;
|
||||
if ( $maxHeight < $scaleHeight ) $maxHeight = $scaleHeight;
|
||||
}
|
||||
$displayMonitors[] = $monitors[$i];
|
||||
}
|
||||
|
||||
|
||||
echo htmlSelect( 'monitor_id', $monitors_dropdown, $monitor_id, array('onchange'=>'changeMonitor(this);') );
|
||||
|
||||
$cycleWidth = $maxWidth;
|
||||
$cycleHeight = $maxHeight;
|
||||
$zoneCount = 0;
|
||||
|
||||
for( $i = 0; $i < count($displayMonitors); $i += 1 ) {
|
||||
$monitor = $displayMonitors[$i];
|
||||
$monitor['zmc'] = zmcStatus( $monitor );
|
||||
$monitor['zma'] = zmaStatus( $monitor );
|
||||
$monitor['ZoneCount'] = dbFetchOne( 'select count(Id) as ZoneCount from Zones where MonitorId = ?', 'ZoneCount', array($monitor['Id']) );
|
||||
$counts = array();
|
||||
for ( $j = 0; $j < count($eventCounts); $j += 1 ) {
|
||||
$filter = addFilterTerm( $eventCounts[$j]['filter'], count($eventCounts[$j]['filter']['Query']['terms']), array( 'cnj' => 'and', 'attr' => 'MonitorId', 'op' => '=', 'val' => $monitor['Id'] ) );
|
||||
parseFilter( $filter );
|
||||
$counts[] = 'count(if(1'.$filter['sql'].",1,NULL)) AS EventCount$j, SUM(if(1".$filter['sql'].",DiskSpace,NULL)) As DiskSpace$j";
|
||||
$monitor['eventCounts'][$j]['filter'] = $filter;
|
||||
}
|
||||
$sql = 'SELECT '.join($counts,', ').' FROM Events as E where MonitorId = ?';
|
||||
$counts = dbFetchOne( $sql, NULL, array($monitor['Id']) );
|
||||
if ( $counts )
|
||||
$displayMonitors[$i] = $monitor = array_merge( $monitor, $counts );
|
||||
for ( $j = 0; $j < count($eventCounts); $j += 1 ) {
|
||||
$eventCounts[$j]['total'] += $monitor['EventCount'.$j];
|
||||
}
|
||||
$zoneCount += $monitor['ZoneCount'];
|
||||
}
|
||||
?>
|
||||
</span>
|
||||
<?php if ( count($ServersById) > 0 ) { ?>
|
||||
<span class="ServerFilter"><label><?php echo translate('Server')?>:</label>
|
||||
<?php
|
||||
echo htmlSelect( 'ServerFilter', array(''=>'All')+$ServersById, (isset($_SESSION['ServerFilter'])?$_SESSION['ServerFilter']:''), array('onchange'=>'changeFilter(this);') );
|
||||
?>
|
||||
</span>
|
||||
<?php
|
||||
}
|
||||
if ( count($StorageById) > 0 ) { ?>
|
||||
<span class="StorageFilter"><label><?php echo translate('Storage')?>:</label>
|
||||
<?php
|
||||
echo htmlSelect( 'StorageFilter', array(''=>'All')+$StorageById, (isset($_SESSION['StorageFilter'])?$_SESSION['StorageFilter']:''), array('onchange'=>'changeFilter(this);') );
|
||||
?>
|
||||
</span>
|
||||
<?php
|
||||
}
|
||||
?>
|
||||
<span class="StatusFilter"><label><?php echo translate('Status')?>:</label>
|
||||
<?php
|
||||
$status_options = array(
|
||||
''=>'All',
|
||||
'Unknown' => translate('Unknown'),
|
||||
'NotRunning' => translate('NotRunning'),
|
||||
'Running' => translate('Running'),
|
||||
);
|
||||
echo htmlSelect( 'StatusFilter', $status_options, ( isset($_SESSION['StatusFilter']) ? $_SESSION['StatusFilter'] : '' ), array('onchange'=>'changeFilter(this);') );
|
||||
?>
|
||||
</span>
|
||||
</div>
|
||||
<?php echo $filterbar ?>
|
||||
|
||||
<div class="container-fluid">
|
||||
<table class="table table-striped table-hover table-condensed" id="consoleTable">
|
||||
|
@ -385,7 +262,7 @@ for( $monitor_i = 0; $monitor_i < count($displayMonitors); $monitor_i += 1 ) {
|
|||
<td class="colId"><?php echo count($displayMonitors) ?></td>
|
||||
<td class="colLeftButtons" colspan="<?php echo $left_columns -1?>">
|
||||
<input type="button" value="<?php echo translate('Refresh') ?>" onclick="location.reload(true);"/>
|
||||
<input type="button" value="<?php echo translate('AddNewMonitor') ?>" onclick="location.href='index.php?view=add_monitors';"/>
|
||||
<input type="button" value="<?php echo translate('AddNewMonitor') ?>" onclick="location.href='index.php?view=monitor';"/>
|
||||
<!--<input type="button" name="addBtn" value="<?php echo translate('AddNewMonitor') ?>" onclick="addMonitor( this )"/>-->
|
||||
<!-- <?php echo makePopupButton( '?view=monitor', 'zmMonitor0', 'monitor', translate('AddNewMonitor'), (canEdit( 'Monitors' ) && !$user['MonitorIds']) ) ?> -->
|
||||
<?php echo makePopupButton( '?view=filter&filter[terms][0][attr]=DateTime&filter[terms][0][op]=%3c&filter[terms][0][val]=now', 'zmFilter', 'filter', translate('Filters'), canView( 'Events' ) ) ?>
|
||||
|
|
|
@ -8,6 +8,7 @@ function Monitor( monitorData ) {
|
|||
this.alarmState = STATE_IDLE;
|
||||
this.lastAlarmState = STATE_IDLE;
|
||||
this.streamCmdParms = "view=request&request=stream&connkey="+this.connKey;
|
||||
this.onclick=monitorData.onclick;
|
||||
if ( auth_hash )
|
||||
this.streamCmdParms += '&auth='+auth_hash;
|
||||
this.streamCmdTimer = null;
|
||||
|
@ -32,7 +33,7 @@ function Monitor( monitorData ) {
|
|||
if ( this.streamCmdTimer )
|
||||
this.streamCmdTimer = clearTimeout( this.streamCmdTimer );
|
||||
|
||||
var stream = $j('#liveStream'+this.id )[0];
|
||||
var stream = $j('#liveStream'+this.id)[0];
|
||||
if ( respObj.result == 'Ok' ) {
|
||||
this.status = respObj.status;
|
||||
this.alarmState = this.status.state;
|
||||
|
@ -81,9 +82,10 @@ function Monitor( monitorData ) {
|
|||
// Try to reload the image stream.
|
||||
if ( stream )
|
||||
stream.src = stream.src.replace( /auth=\w+/i, 'auth='+this.status.auth );
|
||||
console.log("Changed auth to " + this.status.auth );
|
||||
console.log("Changed auth from " + auth_hash + " to " + this.status.auth );
|
||||
auth_hash = this.status.auth;
|
||||
}
|
||||
} // end if haev a new auth hash
|
||||
} // end if have a new auth hash
|
||||
} else {
|
||||
console.error( respObj.message );
|
||||
// Try to reload the image stream.
|
||||
|
@ -93,7 +95,7 @@ function Monitor( monitorData ) {
|
|||
} else {
|
||||
console.log( 'No stream to reload?' );
|
||||
}
|
||||
}
|
||||
} // end if Ok or not
|
||||
var streamCmdTimeout = statusRefreshTimeout;
|
||||
if ( this.alarmState == STATE_ALARM || this.alarmState == STATE_ALERT )
|
||||
streamCmdTimeout = streamCmdTimeout/5;
|
||||
|
@ -108,17 +110,17 @@ function Monitor( monitorData ) {
|
|||
this.streamCmdReq.send( this.streamCmdParms+"&command="+CMD_QUERY );
|
||||
};
|
||||
|
||||
this.streamCmdReq = new Request.JSON( { url: this.server_url, method: 'get', timeout: AJAX_TIMEOUT, onSuccess: this.getStreamCmdResponse.bind( this ), onTimeout: this.streamCmdQuery.bind( this, true ), link: 'cancel' } );
|
||||
this.streamCmdReq = new Request.JSON( { url: this.server_url, method: 'get', timeout: 1000+AJAX_TIMEOUT, onSuccess: this.getStreamCmdResponse.bind( this ), onTimeout: this.streamCmdQuery.bind( this, true ), link: 'cancel' } );
|
||||
|
||||
requestQueue.addRequest( "cmdReq"+this.id, this.streamCmdReq );
|
||||
}
|
||||
|
||||
function selectLayout( element ) {
|
||||
layout = $(element).get('value');
|
||||
layout = $j(element).val();
|
||||
|
||||
if ( layout_id = parseInt(layout) ) {
|
||||
layout = layouts[layout];
|
||||
console.log("Have layout # " + layout_id);
|
||||
console.log(layout);
|
||||
|
||||
for ( var i = 0; i < monitors.length; i++ ) {
|
||||
monitor = monitors[i];
|
||||
|
@ -131,20 +133,23 @@ console.log("Have layout # " + layout_id);
|
|||
}
|
||||
|
||||
// Apply default layout options, like float left
|
||||
if ( layout.default ) {
|
||||
styles = layout.default;
|
||||
if ( layout.Positions['default'] ) {
|
||||
styles = layout.Positions['default'];
|
||||
for ( style in styles ) {
|
||||
console.log("applying " + style + ': ' + styles[style]);
|
||||
monitor_frame.css(style, styles[style]);
|
||||
}
|
||||
} else {
|
||||
console.log("No default styles to apply" + layout.Positions);
|
||||
} // end if default styles
|
||||
|
||||
if ( layout[monitor.id] ) {
|
||||
styles = layout[monitor.id];
|
||||
if ( layout.Positions['mId'+monitor.id] ) {
|
||||
styles = layout.Positions['mId'+monitor.id];
|
||||
for ( style in styles ) {
|
||||
console.log("applying " + style + ': ' + styles[style]);
|
||||
monitor_frame.css(style, styles[style]);
|
||||
console.log("Applying " + style + ' : ' + styles[style] );
|
||||
}
|
||||
} else {
|
||||
console.log("No Monitor styles to apply");
|
||||
} // end if specific monitor style
|
||||
} // end foreach monitor
|
||||
} // end if a stored layout
|
||||
|
@ -152,7 +157,7 @@ console.log("applying " + style + ': ' + styles[style]);
|
|||
return;
|
||||
}
|
||||
Cookie.write( 'zmMontageLayout', layout_id, { duration: 10*365 } );
|
||||
if ( layout_id != 1 ) { // 'montage_freeform.css' ) {
|
||||
if ( layouts[layout_id].Name != 'Freeform' ) { // 'montage_freeform.css' ) {
|
||||
Cookie.write( 'zmMontageScale', '', { duration: 10*365 } );
|
||||
$('scale').set('value', '' );
|
||||
$('width').set('value', '');
|
||||
|
@ -260,51 +265,70 @@ function changeScale() {
|
|||
Cookie.write( 'zmMontageHeight', '', { duration: 10*365 } );
|
||||
}
|
||||
|
||||
function toGrid(value) {
|
||||
return Math.round(value / 80) * 80;
|
||||
}
|
||||
|
||||
// Makes monitorFrames draggable.
|
||||
function edit_layout(button) {
|
||||
|
||||
// Turn off the onclick on the image.
|
||||
|
||||
for ( var i = 0; i < monitors.length; i++ ) {
|
||||
var monitor = monitors[i];
|
||||
monitor_feed = $j('#imageFeed'+monitor.id)[0];
|
||||
monitor_feed.onclick='';
|
||||
};
|
||||
|
||||
$j('#monitors .monitorFrame').draggable({
|
||||
cursor: 'crosshair',
|
||||
//revert: 'invalid'
|
||||
});
|
||||
$j('#SaveLayout').show();
|
||||
$j('#EditLayout').hide();
|
||||
} // end function edit_layout
|
||||
|
||||
function save_layout(button) {
|
||||
var form=button.form;
|
||||
// In fixed positioning, order doesn't matter. In floating positioning, it does.
|
||||
var Positions = {};
|
||||
for ( var i = 0; i < monitors.length; i++ ) {
|
||||
var monitor = monitors[i];
|
||||
monitor_frame = $j('#monitorFrame'+monitor.id);
|
||||
|
||||
Positions['mId'+monitor.id] = {
|
||||
width: monitor_frame.css('width'),
|
||||
height: monitor_frame.css('height'),
|
||||
top: monitor_frame.css('top'),
|
||||
bottom: monitor_frame.css('bottom'),
|
||||
left: monitor_frame.css('left'),
|
||||
right: monitor_frame.css('right'),
|
||||
position: monitor_frame.css('position'),
|
||||
float: monitor_frame.css('float'),
|
||||
};
|
||||
} // end foreach monitor
|
||||
form.Positions.value = JSON.stringify( Positions );
|
||||
form.submit();
|
||||
}
|
||||
function cancel_layout(button) {
|
||||
$j('#SaveLayout').hide();
|
||||
$j('#EditLayout').show();
|
||||
for ( var i = 0; i < monitors.length; i++ ) {
|
||||
var monitor = monitors[i];
|
||||
monitor_feed = $j('#imageFeed'+monitor.id);
|
||||
monitor_feed.click( monitor.onclick );
|
||||
};
|
||||
selectLayout('#zmMontageLayout');
|
||||
}
|
||||
|
||||
var monitors = new Array();
|
||||
function initPage() {
|
||||
for ( var i = 0; i < monitorData.length; i++ ) {
|
||||
monitors[i] = new Monitor( monitorData[i] );
|
||||
var delay = Math.round( (Math.random()+0.5)*statusRefreshTimeout );
|
||||
monitors[i].start( delay );
|
||||
monitors[i] = new Monitor(monitorData[i]);
|
||||
var delay = Math.round( (Math.random()+0.75)*statusRefreshTimeout );
|
||||
monitors[i].start(delay);
|
||||
}
|
||||
selectLayout($('layout'));
|
||||
|
||||
$j('#monitors .monitorFrame').draggable({
|
||||
cursor: 'crosshair',
|
||||
revert: 'invalid'
|
||||
});
|
||||
|
||||
function toGrid(value) {
|
||||
return Math.round(value / 80) * 80;
|
||||
}
|
||||
|
||||
$j('#monitors').droppable({
|
||||
accept: '#monitors .monitorFrame',
|
||||
drop: function(event, ui) {
|
||||
//console.log(event);
|
||||
$j(this).removeClass('border over');
|
||||
$j(ui.draggable).detach().
|
||||
appendTo($j(this).find('ul')).
|
||||
draggable({
|
||||
containment: '.fw-content',
|
||||
cursor: 'help',
|
||||
grid: [ 80, 80 ]
|
||||
}).
|
||||
css({
|
||||
position: 'absolute',
|
||||
left: toGrid(event.clientX - $j('#monitors').offset().left),
|
||||
top: toGrid(event.clientY - $j('#monitors').offset().top)
|
||||
});
|
||||
},
|
||||
over: function(event, elem) {
|
||||
console.log('over');
|
||||
$j(this).addClass('over');
|
||||
},
|
||||
out: function(event, elem) {
|
||||
$j(this).removeClass('over');
|
||||
}
|
||||
});
|
||||
selectLayout('#zmMontageLayout');
|
||||
}
|
||||
|
||||
// Kick everything off
|
||||
window.addEvent( 'domready', initPage );
|
||||
|
|
|
@ -35,7 +35,8 @@ monitorData[monitorData.length] = {
|
|||
'connKey': <?php echo $monitor->connKey() ?>,
|
||||
'width': <?php echo $monitor->Width() ?>,
|
||||
'height':<?php echo $monitor->Height() ?>,
|
||||
'server_url': '<?php echo $monitor->Server()->Url().(ZM_MIN_STREAMING_PORT?':'.(ZM_MIN_STREAMING_PORT+$monitor->Id()):'').$_SERVER['PHP_SELF'] ?>'
|
||||
'server_url': '<?php echo $monitor->Server()->Url().(ZM_MIN_STREAMING_PORT?':'.(ZM_MIN_STREAMING_PORT+$monitor->Id()):'').$_SERVER['PHP_SELF'] ?>',
|
||||
'onclick': function(){createPopup( '?view=watch&mid=<?php echo $monitor->Id() ?>', 'zmWatch<?php echo $monitor->Id() ?>', 'watch', <?php echo reScale( $monitor->Width(), $monitor->PopupScale() ); ?>, <?php echo reScale( $monitor->Height(), $monitor->PopupScale() ); ?> );}
|
||||
};
|
||||
<?php
|
||||
} // end foreach monitor
|
||||
|
@ -45,7 +46,7 @@ layouts[0] = {}; // reserved, should hold which fields to clear when transitioni
|
|||
<?php
|
||||
foreach ( $layouts as $layout ) {
|
||||
?>
|
||||
layouts[<?php echo $layout->Id() ?>] = <?php echo $layout->Positions() ?>;
|
||||
layouts[<?php echo $layout->Id() ?>] = {"Name":"<?php echo $layout->Name()?>","Positions":<?php echo $layout->Positions() ?>};
|
||||
<?php
|
||||
} // end foreach layout
|
||||
?>
|
||||
|
|
|
@ -59,127 +59,51 @@ if ( isset( $_REQUEST['scale'] ) ) {
|
|||
if ( ! $scale )
|
||||
$scale = 100;
|
||||
|
||||
$focusWindow = true;
|
||||
|
||||
/*
|
||||
$layouts = array(
|
||||
'montage_freeform.css' => translate('MtgDefault'),
|
||||
'montage_2wide.css' => translate('Mtg2widgrd'),
|
||||
'montage_3wide.css' => translate('Mtg3widgrd'),
|
||||
'montage_4wide.css' => translate('Mtg4widgrd'),
|
||||
'montage_3wide50enlarge.css' => translate('Mtg3widgrx'),
|
||||
);
|
||||
foreach ( MontageLayout::find() as $Layout ) {
|
||||
$layouts[$Layout->Id()] = $Layout->Name();
|
||||
}
|
||||
*/
|
||||
$layouts = MontageLayout::find(NULL, array('order'=>"lower('Name')"));
|
||||
$layoutsById = array();
|
||||
foreach ( $layouts as $l ) {
|
||||
$layoutsById[$l->Id()] = $l->Name();
|
||||
}
|
||||
|
||||
|
||||
session_start();
|
||||
|
||||
$layout = '';
|
||||
if ( isset($_COOKIE['zmMontageLayout']) )
|
||||
$layout = $_COOKIE['zmMontageLayout'];
|
||||
if ( isset($_COOKIE['zmMontageLayout']) ) {
|
||||
$layout = $_SESSION['zmMontageLayout'] = $_COOKIE['zmMontageLayout'];
|
||||
Warning("Setting layout by cookie");
|
||||
} elseif ( isset($_SESSION['zmMontageLayout']) ) {
|
||||
$layout = $_SESSION['zmMontageLayout'];
|
||||
Warning("Setting layout by session");
|
||||
}
|
||||
|
||||
$options = array();
|
||||
if ( isset($_COOKIE['zmMontageWidth']) and $_COOKIE['zmMontageWidth'] )
|
||||
$options['width'] = $_COOKIE['zmMontageWidth'];
|
||||
else
|
||||
if ( isset($_COOKIE['zmMontageWidth']) and $_COOKIE['zmMontageWidth'] ) {
|
||||
$_SESSION['zmMontageWidth'] = $options['width'] = $_COOKIE['zmMontageWidth'];
|
||||
} elseif ( isset($_SESSION['zmMontageWidth']) and $_SESSION['zmMontageWidth'] ) {
|
||||
$options['width'] = $_SESSION['zmMontageWidth'];
|
||||
} else
|
||||
$options['width'] = '';
|
||||
|
||||
if ( isset($_COOKIE['zmMontageHeight']) and $_COOKIE['zmMontageHeight'] )
|
||||
$options['height'] = $_COOKIE['zmMontageHeight'];
|
||||
$_SESSION['zmMontageHeight'] = $options['height'] = $_COOKIE['zmMontageHeight'];
|
||||
else if ( isset($_SESSION['zmMontageHeight']) and $_SESSION['zmMontageHeight'] )
|
||||
$options['height'] = $_SESSION['zmMontageHeight'];
|
||||
else
|
||||
$options['height'] = '';
|
||||
session_write_close();
|
||||
|
||||
if ( $scale )
|
||||
$options['scale'] = $scale;
|
||||
|
||||
ob_start();
|
||||
# This will end up with the group_id of the deepest selection
|
||||
$group_id = Group::get_group_dropdowns();
|
||||
$group_dropdowns = ob_get_contents();
|
||||
include('_monitor_filters.php');
|
||||
$filterbar = ob_get_contents();
|
||||
ob_end_clean();
|
||||
|
||||
$groupSql = Group::get_group_sql( $group_id );
|
||||
|
||||
$servers = Server::find_all();
|
||||
$ServersById = array();
|
||||
foreach ( $servers as $S ) {
|
||||
$ServersById[$S->Id()] = $S;
|
||||
}
|
||||
session_start();
|
||||
foreach ( array('ServerFilter','StorageFilter') as $var ) {
|
||||
if ( isset( $_REQUEST[$var] ) ) {
|
||||
if ( $_REQUEST[$var] != '' ) {
|
||||
$_SESSION[$var] = $_REQUEST[$var];
|
||||
} else {
|
||||
unset( $_SESSION[$var] );
|
||||
}
|
||||
} else if ( isset( $_COOKIE[$var] ) ) {
|
||||
if ( $_COOKIE[$var] != '' ) {
|
||||
$_SESSION[$var] = $_COOKIE[$var];
|
||||
} else {
|
||||
unset($_SESSION[$var]);
|
||||
}
|
||||
}
|
||||
}
|
||||
session_write_close();
|
||||
|
||||
$storage_areas = Storage::find_all();
|
||||
$StorageById = array();
|
||||
foreach ( $storage_areas as $S ) {
|
||||
$StorageById[$S->Id()] = $S;
|
||||
}
|
||||
|
||||
$monitor_id = 0;
|
||||
if ( isset( $_REQUEST['monitor_id'] ) ) {
|
||||
$monitor_id = $_REQUEST['monitor_id'];
|
||||
} else if ( isset($_COOKIE['zmMonitorId']) ) {
|
||||
$monitor_id = $_COOKIE['zmMonitorId'];
|
||||
}
|
||||
|
||||
$monitors = array();
|
||||
$monitors_dropdown = array( '' => 'All' );
|
||||
$conditions = array();
|
||||
$values = array();
|
||||
|
||||
if ( $groupSql )
|
||||
$conditions[] = $groupSql;
|
||||
if ( isset($_SESSION['ServerFilter']) ) {
|
||||
$conditions[] = 'ServerId=?';
|
||||
$values[] = $_SESSION['ServerFilter'];
|
||||
}
|
||||
if ( isset($_SESSION['StorageFilter']) ) {
|
||||
$conditions[] = 'StorageId=?';
|
||||
$values[] = $_SESSION['StorageFilter'];
|
||||
}
|
||||
$sql = 'SELECT * FROM Monitors' . ( count($conditions) ? ' WHERE ' . implode(' AND ', $conditions ) : '' ).' ORDER BY Sequence ASC';
|
||||
$monitor_rows = dbFetchAll( $sql, null, $values );
|
||||
|
||||
if ( $monitor_id ) {
|
||||
$found_selected_monitor = false;
|
||||
|
||||
for ( $i = 0; $i < count($monitor_rows); $i++ ) {
|
||||
if ( !visibleMonitor( $monitor_rows[$i]['Id'] ) ) {
|
||||
continue;
|
||||
}
|
||||
$monitors_dropdown[$monitor_rows[$i]['Id']] = $monitor_rows[$i]['Name'];
|
||||
if ( $monitor_rows[$i]['Id'] == $monitor_id ) {
|
||||
$found_selected_monitor = true;
|
||||
}
|
||||
}
|
||||
if ( ! $found_selected_monitor ) {
|
||||
$monitor_id = '';
|
||||
}
|
||||
}
|
||||
|
||||
$monitors = array();
|
||||
foreach( $monitor_rows as $row ) {
|
||||
if ( !visibleMonitor( $row['Id'] ) ) {
|
||||
continue;
|
||||
}
|
||||
if ( $monitor_id and $row['Id'] != $monitor_id )
|
||||
foreach( $displayMonitors as &$row ) {
|
||||
if ( $row['Function'] == 'None' )
|
||||
continue;
|
||||
|
||||
$row['Scale'] = $scale;
|
||||
|
@ -188,14 +112,13 @@ foreach( $monitor_rows as $row ) {
|
|||
if ( ZM_OPT_CONTROL && $row['ControlId'] && $row['Controllable'] )
|
||||
$showControl = true;
|
||||
$row['connKey'] = generateConnKey();
|
||||
$Monitor = $monitors[] = new Monitor( $row );
|
||||
$monitors_dropdown[$Monitor->Id()] = $Monitor->Name();
|
||||
if ( ! isset( $widths[$row['Width']] ) ) {
|
||||
$widths[$row['Width']] = $row['Width'];
|
||||
}
|
||||
if ( ! isset( $heights[$row['Height']] ) ) {
|
||||
$heights[$row['Height']] = $row['Height'];
|
||||
}
|
||||
$monitors[] = new Monitor( $row );
|
||||
} # end foreach Monitor
|
||||
|
||||
xhtmlHeaders(__FILE__, translate('Montage') );
|
||||
|
@ -222,38 +145,27 @@ if ( $showZones ) {
|
|||
}
|
||||
?>
|
||||
</div>
|
||||
<div id="headerControl">
|
||||
<span id="groupControl"><label><?php echo translate('Group') ?>:</label>
|
||||
<?php echo $group_dropdowns; ?>
|
||||
</span>
|
||||
<span id="monitorControl"><label><?php echo translate('Monitor') ?>:</label>
|
||||
<?php echo htmlSelect( 'monitor_id', $monitors_dropdown, $monitor_id, array('onchange'=>'changeMonitor(this);') ); ?>
|
||||
</span>
|
||||
<?php if ( count($ServersById) > 0 ) { ?>
|
||||
<span class="ServerFilter"><label><?php echo translate('Server')?>:</label>
|
||||
<?php
|
||||
echo htmlSelect( 'ServerFilter', array(''=>'All')+$ServersById, (isset($_SESSION['ServerFilter'])?$_SESSION['ServerFilter']:''), array('onchange'=>'changeFilter(this);') );
|
||||
?>
|
||||
</span>
|
||||
<?php
|
||||
}
|
||||
if ( count($StorageById) > 0 ) { ?>
|
||||
<span class="StorageFilter"><label><?php echo translate('Storage')?>:</label>
|
||||
<?php
|
||||
echo htmlSelect( 'StorageFilter', array(''=>'All')+$StorageById, (isset($_SESSION['StorageFilter'])?$_SESSION['StorageFilter']:''), array('onchange'=>'changeFilter(this);') );
|
||||
?>
|
||||
</span>
|
||||
<?php
|
||||
}
|
||||
?>
|
||||
<br/>
|
||||
<span id="widthControl"><label><?php echo translate('Width') ?>:</label><?php echo htmlSelect( 'width', $widths, $options['width'], 'changeSize(this);' ); ?></span>
|
||||
<span id="heightControl"><label><?php echo translate('Height') ?>:</label><?php echo htmlSelect( 'height', $heights, $options['height'], 'changeSize(this);' ); ?></span>
|
||||
<span id="scaleControl"><label><?php echo translate('Scale') ?>:</label><?php echo htmlSelect( 'scale', $scales, $scale, 'changeScale(this);' ); ?></span>
|
||||
<span id="layoutControl">
|
||||
<label for="layout"><?php echo translate('Layout') ?>:</label>
|
||||
<?php echo htmlSelect( 'layout', $layoutsById, $layout, 'selectLayout(this);' )?>
|
||||
</span>
|
||||
<?php echo $filterbar ?>
|
||||
<div id="sizeControl">
|
||||
<form action="index.php?view=montage" method="post">
|
||||
<input type="hidden" name="object" value="MontageLayout"/>
|
||||
<input type="hidden" name="action" value="Save"/>
|
||||
|
||||
<span id="widthControl"><label><?php echo translate('Width') ?>:</label><?php echo htmlSelect( 'width', $widths, $options['width'], 'changeSize(this);' ); ?></span>
|
||||
<span id="heightControl"><label><?php echo translate('Height') ?>:</label><?php echo htmlSelect( 'height', $heights, $options['height'], 'changeSize(this);' ); ?></span>
|
||||
<span id="scaleControl"><label><?php echo translate('Scale') ?>:</label><?php echo htmlSelect( 'scale', $scales, $scale, 'changeScale(this);' ); ?></span>
|
||||
<span id="layoutControl">
|
||||
<label for="layout"><?php echo translate('Layout') ?>:</label>
|
||||
<?php echo htmlSelect( 'zmMontageLayout', $layoutsById, $layout, array( 'onchange'=>'selectLayout(this);', 'id'=>'zmMontageLayout') ); ?>
|
||||
</span>
|
||||
<input type="hidden" name="Positions"/>
|
||||
<input type="button" id="EditLayout" value="<?php echo translate('EditLayout') ?>" onclick="edit_layout(this);"/>
|
||||
<span id="SaveLayout" style="display:none;">
|
||||
<input type="text" name="Name" placeholder="Enter new name for layout if desired" />
|
||||
<input type="button" value="<?php echo translate('Save') ?>" onclick="save_layout(this);"/>
|
||||
<input type="button" value="Cancel" onclick="cancel_layout(this);"/>
|
||||
</span>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
<div id="content">
|
||||
|
@ -262,7 +174,7 @@ echo htmlSelect( 'StorageFilter', array(''=>'All')+$StorageById, (isset($_SESSIO
|
|||
foreach ( $monitors as $monitor ) {
|
||||
$connkey = $monitor->connKey(); // Minor hack
|
||||
?>
|
||||
<div id="monitorFrame<?php echo $monitor->Id() ?>" class="monitorFrame" title="<?php echo $monitor->Id() . ' ' .$monitor->Name() ?>">
|
||||
<div id="monitorFrame<?php echo $monitor->Id() ?>" class="monitorFrame" title="<?php echo $monitor->Id() . ' ' .$monitor->Name() ?>" style="<?php echo $options['width'] ? 'width:'.$options['width'].'px;':''?>">
|
||||
<div id="monitor<?php echo $monitor->Id() ?>" class="monitor idle">
|
||||
<div id="imageFeed<?php echo $monitor->Id() ?>" class="imageFeed" onclick="createPopup( '?view=watch&mid=<?php echo $monitor->Id() ?>', 'zmWatch<?php echo $monitor->Id() ?>', 'watch', <?php echo reScale( $monitor->Width(), $monitor->PopupScale() ); ?>, <?php echo reScale( $monitor->Height(), $monitor->PopupScale() ); ?> );">
|
||||
<?php
|
||||
|
@ -303,16 +215,13 @@ foreach ( $monitors as $monitor ) {
|
|||
$row['Coords'] = pointsToCoords( $row['Points'] );
|
||||
$row['AreaCoords'] = preg_replace( '/\s+/', ',', $row['Coords'] );
|
||||
$zones[] = $row;
|
||||
}
|
||||
|
||||
} // end foreach Zone
|
||||
?>
|
||||
|
||||
<svg class="zones" id="zones<?php echo $monitor->Id() ?>" style="position:absolute; top: 0; left: 0; background: none; width: <?php echo $width ?>px; height: <?php echo $height ?>px;">
|
||||
<?php
|
||||
foreach( array_reverse($zones) as $zone ) {
|
||||
?>
|
||||
<polygon points="<?php echo $zone['AreaCoords'] ?>" class="<?php echo $zone['Type']?>" />
|
||||
<?php
|
||||
echo '<polygon points="'. $zone['AreaCoords'] .'" class="'. $zone['Type'].'" />';
|
||||
} // end foreach zone
|
||||
?>
|
||||
Sorry, your browser does not support inline SVG
|
||||
|
|
|
@ -55,62 +55,10 @@ if ( !canView( 'Events' ) ) {
|
|||
}
|
||||
|
||||
ob_start();
|
||||
# This will end up with the group_id of the deepest selection
|
||||
$group_id = Group::get_group_dropdowns();
|
||||
$group_dropdowns = ob_get_contents();
|
||||
include('_monitor_filters.php');
|
||||
$filter_bar = ob_get_contents();
|
||||
ob_end_clean();
|
||||
|
||||
$groupSql = Group::get_group_sql( $group_id );
|
||||
|
||||
$servers = Server::find_all();
|
||||
$ServersById = array();
|
||||
foreach ( $servers as $S ) {
|
||||
$ServersById[$S->Id()] = $S;
|
||||
}
|
||||
$storage_areas = Storage::find_all();
|
||||
$StorageById = array();
|
||||
foreach ( $storage_areas as $S ) {
|
||||
$StorageById[$S->Id()] = $S;
|
||||
}
|
||||
session_start();
|
||||
foreach ( array('minTime','maxTime','ServerFilter','StorageFilter') as $var ) {
|
||||
if ( isset( $_REQUEST[$var] ) ) {
|
||||
if ( $_REQUEST[$var] != '' ) {
|
||||
$_SESSION[$var] = $_REQUEST[$var];
|
||||
} else {
|
||||
unset( $_SESSION[$var] );
|
||||
}
|
||||
} else if ( isset( $_COOKIE[$var] ) ) {
|
||||
if ( $_COOKIE[$var] != '' ) {
|
||||
$_SESSION[$var] = $_COOKIE[$var];
|
||||
} else {
|
||||
unset($_SESSION[$var]);
|
||||
}
|
||||
}
|
||||
}
|
||||
session_write_close();
|
||||
|
||||
$monitor_id = 0;
|
||||
if ( isset( $_REQUEST['monitor_id'] ) ) {
|
||||
$monitor_id = $_REQUEST['monitor_id'];
|
||||
} else if ( isset($_COOKIE['zmMonitorId']) ) {
|
||||
$monitor_id = $_COOKIE['zmMonitorId'];
|
||||
}
|
||||
|
||||
$conditions = array();
|
||||
$values = array();
|
||||
|
||||
if ( $groupSql )
|
||||
$conditions[] = $groupSql;
|
||||
if ( isset($_SESSION['ServerFilter']) ) {
|
||||
$conditions[] = 'ServerId=?';
|
||||
$values[] = $_SESSION['ServerFilter'];
|
||||
}
|
||||
if ( isset($_SESSION['StorageFilter']) ) {
|
||||
$conditions[] = 'StorageId=?';
|
||||
$values[] = $_SESSION['StorageFilter'];
|
||||
}
|
||||
|
||||
// Note that this finds incomplete events as well, and any frame records written, but still cannot "see" to the end frame
|
||||
// if the bulk record has not been written - to be able to include more current frames reduce bulk frame sizes (event size can be large)
|
||||
// Note we round up just a bit on the end time as otherwise you get gaps, like 59.78 to 00 in the next second, which can give blank frames when moved through slowly.
|
||||
|
@ -141,18 +89,12 @@ $frameSql = '
|
|||
// This program only calls itself with the time range involved -- it does all monitors (the user can see, in the called group) all the time
|
||||
|
||||
if ( ! empty( $user['MonitorIds'] ) ) {
|
||||
$eventsSql .= ' AND M.Id IN ('.$user['MonitorIds'].')';
|
||||
$monitorsSql .= ' AND Id IN ('.$user['MonitorIds'].')';
|
||||
$monitor_ids = explode(',',$user['MonitorIds']);
|
||||
$conditions[] .= 'Id IN ('.array_map( function(){return '?';}, $monitor_ids ) . ')';
|
||||
array_push( $values, $monitor_ids );
|
||||
$frameSql .= ' AND E.MonitorId IN ('.$user['MonitorIds'].')';
|
||||
$eventsSql .= ' AND M.Id IN ('.$user['MonitorIds'].')';
|
||||
$frameSql .= ' AND E.MonitorId IN ('.$user['MonitorIds'].')';
|
||||
}
|
||||
if ( $monitor_id ) {
|
||||
$conditions[] = 'Id=?';
|
||||
$values[] = $monitor_id;
|
||||
$eventsSql .= ' AND M.Id='.$monitor_id;
|
||||
$frameSql .= ' AND E.MonitorId='.$monitor_id;
|
||||
$frameSql .= ' AND E.MonitorId='.$monitor_id;
|
||||
}
|
||||
|
||||
// Parse input parameters -- note for future, validate/clean up better in case we don't get called from self.
|
||||
|
@ -160,7 +102,6 @@ if ( $monitor_id ) {
|
|||
|
||||
// The default (nothing at all specified) is for 1 hour so we do not read the whole database
|
||||
|
||||
|
||||
if ( !isset($_REQUEST['minTime']) && !isset($_REQUEST['maxTime']) ) {
|
||||
$time = time();
|
||||
$maxTime = strftime("%FT%T",$time);
|
||||
|
@ -180,7 +121,7 @@ if ( (strtotime($maxTime) - strtotime($minTime))/(365*24*3600) > 30 ) {
|
|||
$maxTime = null;
|
||||
}
|
||||
|
||||
$fitMode=1;
|
||||
$fitMode = 1;
|
||||
if (isset($_REQUEST['fit']) && $_REQUEST['fit']=='0' )
|
||||
$fitMode = 0;
|
||||
|
||||
|
@ -196,7 +137,7 @@ if ( isset($_REQUEST['speed']) )
|
|||
else
|
||||
$defaultSpeed = 1;
|
||||
|
||||
$speedIndex=5; // default to 1x
|
||||
$speedIndex = 5; // default to 1x
|
||||
for ( $i = 0; $i < count($speeds); $i++ ) {
|
||||
if ( $speeds[$i] == $defaultSpeed ) {
|
||||
$speedIndex = $i;
|
||||
|
@ -225,10 +166,10 @@ if ( isset($minTime) && isset($maxTime) ) {
|
|||
}
|
||||
$frameSql .= ' GROUP BY E.Id, E.MonitorId, F.TimeStamp, F.Delta ORDER BY E.MonitorId, F.TimeStamp ASC';
|
||||
|
||||
|
||||
$monitors = array();
|
||||
$monitorsSql = 'SELECT * FROM Monitors' . ( count($conditions) ? ' WHERE ' . implode(' AND ', $conditions ) : '' ).' ORDER BY Sequence ASC';
|
||||
foreach( dbFetchAll( $monitorsSql, null, $values ) as $row ) {
|
||||
foreach( $displayMonitors as &$row ) {
|
||||
if ( $row['Function'] == 'None' )
|
||||
continue;
|
||||
$Monitor = new Monitor( $row );
|
||||
$monitors[] = $Monitor;
|
||||
}
|
||||
|
@ -243,32 +184,7 @@ xhtmlHeaders(__FILE__, translate('MontageReview') );
|
|||
<form action="<?php echo $_SERVER['PHP_SELF'] ?>" method="get">
|
||||
<input type="hidden" name="view" value="montagereview"/>
|
||||
<div id="header">
|
||||
<div id="headerControl">
|
||||
<span id="groupControl"><label><?php echo translate('Group') ?>:</label>
|
||||
<?php echo $group_dropdowns; ?>
|
||||
</span>
|
||||
<span id="monitorControl"><label><?php echo translate('Monitor') ?>:</label>
|
||||
<?php Group::get_monitors_dropdown( $groupSql ? array( 'groupSql'=>$groupSql) : null ); ?>
|
||||
</span>
|
||||
<?php
|
||||
if ( count($ServersById) > 0 ) { ?>
|
||||
<span class="ServerFilter"><label><?php echo translate('Server')?>:</label>
|
||||
<?php
|
||||
echo htmlSelect( 'ServerFilter', array(''=>'All')+$ServersById, (isset($_SESSION['ServerFilter'])?$_SESSION['ServerFilter']:''), array('onchange'=>'changeFilter(this);') );
|
||||
?>
|
||||
</span>
|
||||
<?php
|
||||
}
|
||||
if ( count($StorageById) > 0 ) { ?>
|
||||
<span class="StorageFilter"><label><?php echo translate('Storage')?>:</label>
|
||||
<?php
|
||||
echo htmlSelect( 'StorageFilter', array(''=>'All')+$StorageById, (isset($_SESSION['StorageFilter'])?$_SESSION['StorageFilter']:''), array('onchange'=>'changeFilter(this);') );
|
||||
?>
|
||||
</span>
|
||||
<?php
|
||||
}
|
||||
?>
|
||||
|
||||
<?php echo $filter_bar ?>
|
||||
<div id="DateTimeDiv">
|
||||
<input type="datetime-local" name="minTime" id="minTime" value="<?php echo preg_replace('/ /', 'T', $minTime ) ?>" onchange="changeDateTime(this);"> to
|
||||
<input type="datetime-local" name="maxTime" id="maxTime" value="<?php echo preg_replace('/ /', 'T', $maxTime ) ?>" onchange="changeDateTime(this);">
|
||||
|
|
|
@ -25,6 +25,11 @@ if ( !canView( 'Stream' ) ) {
|
|||
return;
|
||||
}
|
||||
|
||||
if ( ! isset($_REQUEST['mid']) ) {
|
||||
$view = 'error';
|
||||
return;
|
||||
}
|
||||
|
||||
// This is for input sanitation
|
||||
$mid = intval( $_REQUEST['mid'] );
|
||||
if ( ! visibleMonitor( $mid ) ) {
|
||||
|
|
Loading…
Reference in New Issue