-
-
- : +
- :
-
+
diff --git a/db/zm_create.sql.in b/db/zm_create.sql.in index 934e77bdb..9071cdfd8 100644 --- a/db/zm_create.sql.in +++ b/db/zm_create.sql.in @@ -325,7 +325,7 @@ CREATE TABLE `Groups` ( ) ENGINE=@ZM_MYSQL_ENGINE@; -- ---Table structure for table `Groups_Monitors` +-- Table structure for table `Groups_Monitors` -- DROP TABLE IF EXISTS `Groups_Monitors`; @@ -701,7 +701,7 @@ CREATE TABLE `Storage` ( -- -- Create a default storage location -- -insert into Storage VALUES (NULL, '/var/cache/zoneminder/events', 'Default', 'local', NULL ); +insert into Storage VALUES (NULL, '/var/cache/zoneminder/events', 'Default', 'local', NULL, 'Medium', 0 ); /*!40101 SET SQL_MODE=@OLD_SQL_MODE */; /*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */; @@ -723,22 +723,6 @@ 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 -- - `Id` int(10) unsigned NOT NULL auto_increment, - `Name` varchar(64) NOT NULL default '', - `Query` text NOT NULL, - `AutoArchive` tinyint(3) unsigned NOT NULL default '0', - `AutoVideo` tinyint(3) unsigned NOT NULL default '0', - `AutoUpload` tinyint(3) unsigned NOT NULL default '0', - `AutoEmail` tinyint(3) unsigned NOT NULL default '0', - `AutoMessage` tinyint(3) unsigned NOT NULL default '0', - `AutoExecute` tinyint(3) unsigned NOT NULL default '0', - `AutoExecuteCmd` tinytext, - `AutoDelete` tinyint(3) unsigned NOT NULL default '0', - `AutoMove` tinyint(3) unsigned NOT NULL default '0', - `AutoMoveTo` smallint(5) unsigned NOT NULL default 0, - `UpdateDiskSpace` tinyint(3) unsigned NOT NULL default '0', - `Background` tinyint(1) unsigned NOT NULL default '0', - `Concurrent` tinyint(1) unsigned NOT NULL default '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/*AutoArchive*/,0/*AutoVideo*/,0/*AutoUpload*/,0/*AutoEmail*/,0/*AutoMessage*/,0/*AutoExecute*/,'',1/*AutoDelete*/,0/*AutoMove*/,0/*MoveTo*/,0/*UpdateDiskSpace*/,1/*Background*/,0/*Concurrent*/); insert into Filters values (NULL,'Update DiskSpace','{"terms":[{"attr":"DiskSpace","op":"IS","val":"NULL"}]}',0,0,0,0,0,0,'',0,0,0,1,1,0); @@ -861,16 +845,20 @@ INSERT INTO ZonePresets VALUES (5,'Best, low sensitivity','Active','Percent','Bl INSERT INTO ZonePresets VALUES (6,'Best, medium sensitivity','Active','Percent','Blobs',40,NULL,16,NULL,5,5,12,NULL,10,NULL,1,NULL,0,0); INSERT INTO ZonePresets VALUES (7,'Best, high sensitivity','Active','Percent','Blobs',20,NULL,8,NULL,3,3,6,NULL,5,NULL,1,NULL,0,0); +DROP TABLE IF EXISTS Maps; + CREATE TABLE Maps ( `Id` int(10) unsigned NOT NULL auto_increment, - `Name` TEXT NOT NULL, - `Filename` TEXT NOT NULL default '', + `Name` VARCHAR(64) NOT NULL, + `Filename` VARCHAR(64) NOT NULL default '', `NumCoords` tinyint(3) unsigned NOT NULL default '0', `Coords` tinytext NOT NULL, `ParentId` int(1) unsigned, PRIMARY KEY (`Id`) ); +DROP TABLE IF EXISTS MontageLayout; + CREATE TABLE MontageLayouts ( `Id` int(10) unsigned NOT NULL auto_increment, `Name` TEXT NOT NULL, diff --git a/db/zm_update-1.31.20.sql b/db/zm_update-1.31.20.sql index 4f0d9ee47..358f15093 100644 --- a/db/zm_update-1.31.20.sql +++ b/db/zm_update-1.31.20.sql @@ -244,3 +244,32 @@ SET @s = (SELECT IF( PREPARE stmt FROM @s; EXECUTE stmt; + +UPDATE Monitors INNER JOIN ( + SELECT MonitorId, + COUNT(Id) AS TotalEvents, + SUM(DiskSpace) AS TotalEventDiskSpace, + SUM(IF(Archived,1,0)) AS ArchivedEvents, + SUM(IF(Archived,DiskSpace,0)) AS ArchivedEventDiskSpace, + SUM(IF(StartTime > DATE_SUB(NOW(), INTERVAL 1 hour),1,0)) AS HourEvents, + SUM(IF(StartTime > DATE_SUB(NOW(), INTERVAL 1 hour),DiskSpace,0)) AS HourEventDiskSpace, + SUM(IF(StartTime > DATE_SUB(NOW(), INTERVAL 1 day),1,0)) AS DayEvents, + SUM(IF(StartTime > DATE_SUB(NOW(), INTERVAL 1 day),DiskSpace,0)) AS DayEventDiskSpace, + SUM(IF(StartTime > DATE_SUB(NOW(), INTERVAL 1 week),1,0)) AS WeekEvents, + SUM(IF(StartTime > DATE_SUB(NOW(), INTERVAL 1 week),DiskSpace,0)) AS WeekEventDiskSpace, + SUM(IF(StartTime > DATE_SUB(NOW(), INTERVAL 1 month),1,0)) AS MonthEvents, + SUM(IF(StartTime > DATE_SUB(NOW(), INTERVAL 1 month),DiskSpace,0)) AS MonthEventDiskSpace + FROM Events GROUP BY MonitorId + ) AS E ON E.MonitorId=Monitors.Id SET + Monitors.TotalEvents = E.TotalEvents, + Monitors.TotalEventDiskSpace = E.TotalEventDiskSpace, + Monitors.ArchivedEvents = E.ArchivedEvents, + Monitors.ArchivedEventDiskSpace = E.ArchivedEventDiskSpace, + Monitors.HourEvents = E.HourEvents, + Monitors.HourEventDiskSpace = E.HourEventDiskSpace, + Monitors.DayEvents = E.DayEvents, + Monitors.DayEventDiskSpace = E.DayEventDiskSpace, + Monitors.WeekEvents = E.WeekEvents, + Monitors.WeekEventDiskSpace = E.WeekEventDiskSpace, + Monitors.MonthEvents = E.MonthEvents, + Monitors.MonthEventDiskSpace = E.MonthEventDiskSpace; diff --git a/scripts/ZoneMinder/lib/ZoneMinder/ConfigData.pm.in b/scripts/ZoneMinder/lib/ZoneMinder/ConfigData.pm.in index 923654b31..00015ae24 100644 --- a/scripts/ZoneMinder/lib/ZoneMinder/ConfigData.pm.in +++ b/scripts/ZoneMinder/lib/ZoneMinder/ConfigData.pm.in @@ -1451,6 +1451,17 @@ our @options = ( type => $types{boolean}, category => 'logging', }, + { + name => 'ZM_WEB_TITLE', + default => 'ZoneMinder', + description => 'The title displayed wherever the site references itself.', + help => q` + If you want the site to identify as something other than ZoneMinder, change this here. + It can be used to more accurately identify this installation from others. + `, + type => $types{string}, + category => 'web', + }, { name => 'ZM_WEB_TITLE_PREFIX', default => 'ZM', @@ -1464,6 +1475,27 @@ our @options = ( type => $types{string}, category => 'web', }, + { + name => 'ZM_HOME_URL', + default => 'http://zoneminder.com', + description => 'The url used in the home/logo area of the navigation bar.', + help => q` + By default this takes you to the zoneminder.com website, + but perhaps you would prefer it to take you somewhere else. + `, + type => $types{string}, + category => 'web', + }, + { + name => 'ZM_HOME_CONTENT', + default => 'ZoneMinder', + description => 'The content of the home button.', + help => q` + You may wish to set this to empty if you are using css to put a background image on it. + `, + type => $types{string}, + category => 'web', + }, { name => 'ZM_WEB_CONSOLE_BANNER', default => '', diff --git a/scripts/ZoneMinder/lib/ZoneMinder/Event.pm b/scripts/ZoneMinder/lib/ZoneMinder/Event.pm index 52a25ad17..134cfa794 100644 --- a/scripts/ZoneMinder/lib/ZoneMinder/Event.pm +++ b/scripts/ZoneMinder/lib/ZoneMinder/Event.pm @@ -359,7 +359,7 @@ sub delete_files { my $storage_path = $Storage->Path(); if ( ! $storage_path ) { - Fatal("Empty storage path when deleting files for event $$event{Id} with storage id $$event{StorageId} "); + Error("Empty storage path when deleting files for event $$event{Id} with storage id $$event{StorageId} "); return; } diff --git a/scripts/ZoneMinder/lib/ZoneMinder/Logger.pm b/scripts/ZoneMinder/lib/ZoneMinder/Logger.pm index a81a4d87b..2d00a7781 100644 --- a/scripts/ZoneMinder/lib/ZoneMinder/Logger.pm +++ b/scripts/ZoneMinder/lib/ZoneMinder/Logger.pm @@ -141,7 +141,8 @@ sub new { $this->{idArgs} = ''; $this->{level} = INFO; -if (-t STDIN) { + $this->{hasTerm} = -t STDERR; +if ( $this->{hasTerm} ) { $this->{termLevel} = INFO; } else { $this->{termLevel} = NOLOG; @@ -152,7 +153,6 @@ if (-t STDIN) { $this->{effectiveLevel} = INFO; $this->{autoFlush} = 1; - $this->{hasTerm} = -t STDERR; ( $this->{fileName} = $0 ) =~ s|^.*/||; $this->{logPath} = $Config{ZM_PATH_LOGS}; diff --git a/scripts/ZoneMinder/lib/ZoneMinder/Memory.pm.in b/scripts/ZoneMinder/lib/ZoneMinder/Memory.pm.in index 27afb05ff..2386c5d6f 100644 --- a/scripts/ZoneMinder/lib/ZoneMinder/Memory.pm.in +++ b/scripts/ZoneMinder/lib/ZoneMinder/Memory.pm.in @@ -349,14 +349,15 @@ sub zmMemRead { } elsif ( $type =~ /^uint8\[\d+\]$/ ) { ( $value ) = unpack( 'C'.$size, $data ); } else { - Fatal( "Unexpected type '".$type."' found for '".$field."'" ); + Error( "Unexpected type '".$type."' found for '".$field."'" ); + next; } - push( @values, $value ); + push @values, $value; } if ( wantarray() ) { - return( @values ) + return @values; } - return( $values[0] ); + return $values[0]; } sub zmMemInvalidate { diff --git a/scripts/ZoneMinder/lib/ZoneMinder/Memory/Mapped.pm b/scripts/ZoneMinder/lib/ZoneMinder/Memory/Mapped.pm index 5a4c8e592..d782c6c9a 100644 --- a/scripts/ZoneMinder/lib/ZoneMinder/Memory/Mapped.pm +++ b/scripts/ZoneMinder/lib/ZoneMinder/Memory/Mapped.pm @@ -77,19 +77,18 @@ sub zmMemAttach { my ( $monitor, $size ) = @_; if ( ! $size ) { Error( "No size passed to zmMemAttach for monitor $$monitor{Id}\n" ); - return( undef ); + return undef; } if ( !defined($monitor->{MMapAddr}) ) { - my $mmap_file = $Config{ZM_PATH_MAP}."/zm.mmap.".$monitor->{Id}; + my $mmap_file = $Config{ZM_PATH_MAP}.'/zm.mmap.'.$monitor->{Id}; if ( ! -e $mmap_file ) { Error( sprintf( "Memory map file '%s' does not exist. zmc might not be running." , $mmap_file ) ); - return ( undef ); + return undef; } - my $mmap_file_size = -s $mmap_file; if ( $mmap_file_size < $size ) { @@ -99,25 +98,25 @@ sub zmMemAttach { , $mmap_file_size ) ); - return ( undef ); + return undef; } my $MMAP; if ( !open( $MMAP, '+<', $mmap_file ) ) { - Error( sprintf( "Can't open memory map file '%s': $!\n", $mmap_file ) ); - return( undef ); + Error( sprintf( "Can't open memory map file '%s': $!", $mmap_file ) ); + return undef; } my $mmap = undef; my $mmap_addr = mmap( $mmap, $size, PROT_READ|PROT_WRITE, MAP_SHARED, $MMAP ); if ( !$mmap_addr || !$mmap ) { Error( sprintf( "Can't mmap to file '%s': $!\n", $mmap_file ) ); close( $MMAP ); - return( undef ); + return undef; } $monitor->{MMapHandle} = $MMAP; $monitor->{MMapAddr} = $mmap_addr; $monitor->{MMap} = \$mmap; } - return( !undef ); + return !undef; } sub zmMemDetach { @@ -149,10 +148,10 @@ sub zmMemGet { , $monitor->{Id} ) ); - return( undef ); + return undef; } my $data = substr( $$mmap, $offset, $size ); - return( $data ); + return $data; } sub zmMemPut { diff --git a/scripts/zmaudit.pl.in b/scripts/zmaudit.pl.in index 39f5cdaee..1b2e654f4 100644 --- a/scripts/zmaudit.pl.in +++ b/scripts/zmaudit.pl.in @@ -237,7 +237,7 @@ MAIN: while( $loop ) { } elsif ( $$Storage{Scheme} eq 'Medium' ) { foreach my $event_dir ( glob("$monitor_dir/*/*") ) { next if ! -d $event_dir; - my ( $date, $event_id ) = $event_dir =~ /^$monitor_dir\/(\d{4}\-\d{2}\-\d{2})\/(\d\+)$/; + my ( $date, $event_id ) = $event_dir =~ /^$monitor_dir\/(\d{4}\-\d{2}\-\d{2})\/(\d+)$/; if ( ! $event_id ) { Debug("Unable to parse date/event_id from $event_dir"); next; diff --git a/scripts/zmwatch.pl.in b/scripts/zmwatch.pl.in index 2e6953cab..57ffd49a6 100644 --- a/scripts/zmwatch.pl.in +++ b/scripts/zmwatch.pl.in @@ -69,12 +69,10 @@ delete @ENV{qw(IFS CDPATH ENV BASH_ENV)}; logInit(); logSetSignal(); -Info( "Watchdog starting\n" ); -Info( "Watchdog pausing for ".START_DELAY." seconds\n" ); +Info( "Watchdog starting, pausing for ".START_DELAY." seconds\n" ); sleep( START_DELAY ); my $dbh = zmDbConnect(); - my $sql = $Config{ZM_SERVER_ID} ? 'SELECT * FROM Monitors WHERE ServerId=?' : 'SELECT * FROM Monitors'; my $sth = $dbh->prepare_cached( $sql ) or Fatal( "Can't prepare '$sql': ".$dbh->errstr() ); @@ -84,7 +82,6 @@ while( 1 ) { my $res = $sth->execute( $Config{ZM_SERVER_ID} ? $Config{ZM_SERVER_ID} : () ) or Fatal( "Can't execute: ".$sth->errstr() ); while( my $monitor = $sth->fetchrow_hashref() ) { - my $now = time(); next if $monitor->{Function} eq 'None'; my $restart = 0; @@ -99,38 +96,41 @@ while( 1 ) { } Debug( "LastWriteTime is = $capture_time." ); if ( !$capture_time ) { - my $startup_time = zmGetStartupTime( $monitor ); - if ( $now - $startup_time > $Config{ZM_WATCH_MAX_DELAY} ) { - Info( "Restarting capture daemon for ".$monitor->{Name}.", no image since startup. Startup time was $startup_time - now $now > $Config{ZM_WATCH_MAX_DELAY}\n" ); - $restart = 1; - } else { + my $startup_time = zmGetStartupTime( $monitor ); + if ( $now - $startup_time > $Config{ZM_WATCH_MAX_DELAY} ) { + Info( "Restarting capture daemon for ".$monitor->{Name}.", no image since startup. Startup time was $startup_time - now $now > $Config{ZM_WATCH_MAX_DELAY}\n" ); + $restart = 1; + } else { # We can't get the last capture time so can't be sure it's died, it might just be starting up. zmMemInvalidate( $monitor ); next; - } + } } - if ( ! $restart ) { - my $max_image_delay = ( $monitor->{MaxFPS} - &&($monitor->{MaxFPS}>0) - &&($monitor->{MaxFPS}<1) - ) ? (3/$monitor->{MaxFPS}) - : $Config{ZM_WATCH_MAX_DELAY} - ; - my $image_delay = $now-$capture_time; - Debug( "Monitor $monitor->{Id} last captured $image_delay seconds ago, max is $max_image_delay\n" ); - if ( $image_delay > $max_image_delay ) { - Info( "Restarting capture daemon for " - .$monitor->{Name}.", time since last capture $image_delay seconds ($now-$capture_time)\n" - ); - $restart = 1; - } - } # end if ! restart + if ( ! $restart ) { + my $max_image_delay = ( $monitor->{MaxFPS} + &&($monitor->{MaxFPS}>0) + &&($monitor->{MaxFPS}<1) + ) ? (3/$monitor->{MaxFPS}) + : $Config{ZM_WATCH_MAX_DELAY} + ; + my $image_delay = $now-$capture_time; + Debug( "Monitor $monitor->{Id} last captured $image_delay seconds ago, max is $max_image_delay\n" ); + if ( $image_delay > $max_image_delay ) { + Info( "Restarting capture daemon for " + .$monitor->{Name}.", time since last capture $image_delay seconds ($now-$capture_time)\n" + ); + $restart = 1; + } + } # end if ! restart } else { Info( "Restarting capture daemon for ".$monitor->{Name}.", shared data not valid\n" ); $restart = 1; } if ( $restart ) { + # Because zma depends on zmc, and zma can hold the shm in place, preventing zmc from using the space in /dev/shm, + # we need to stop zma before restarting zmc. + runCommand( "zmdc.pl stop zma -m $$monitor{Id}" ) if $monitor->{Function} ne 'Monitor'; my $command; if ( $monitor->{Type} eq 'Local' ) { $command = "zmdc.pl restart zmc -d $monitor->{Device}"; @@ -138,6 +138,7 @@ while( 1 ) { $command = "zmdc.pl restart zmc -m $monitor->{Id}"; } runCommand( $command ); + runCommand( "zmdc.pl start zma -m $$monitor{Id}" ) if $monitor->{Function} ne 'Monitor'; } elsif ( $monitor->{Function} ne 'Monitor' ) { # Now check analysis daemon $restart = 0; diff --git a/src/zm_event.cpp b/src/zm_event.cpp index c72383a30..cafb66809 100644 --- a/src/zm_event.cpp +++ b/src/zm_event.cpp @@ -97,7 +97,6 @@ Event::Event( Monitor *p_monitor, struct timeval p_start_time, const std::string max_score = 0; have_video_keyframe = false; - struct stat statbuf; char id_file[PATH_MAX]; struct tm *stime = localtime( &start_time.tv_sec ); @@ -399,7 +398,10 @@ void Event::AddFramesInternal( int n_frames, int start_frame, Image **images, st static char event_file[PATH_MAX]; snprintf( event_file, sizeof(event_file), staticConfig.capture_file_format, path, frames ); - if ( ! ( monitor->GetOptSaveJPEGs() & 3 ) ) { + if ( monitor->GetOptSaveJPEGs() & 1 ) { + Debug( 1, "Writing pre-capture frame %d", frames ); + WriteFrameImage( images[i], *(timestamps[i]), event_file ); + } else { //If this is the first frame, we should add a thumbnail to the event directory // ICON: We are working through the pre-event frames so this snapshot won't // neccessarily be of the motion. But some events are less than 10 frames, @@ -409,10 +411,9 @@ void Event::AddFramesInternal( int n_frames, int start_frame, Image **images, st WriteFrameImage( images[i], *(timestamps[i]), snapshot_file.c_str() ); } } - if ( monitor->GetOptSaveJPEGs() & 1 ) { - Debug( 1, "Writing pre-capture frame %d", frames ); - WriteFrameImage( images[i], *(timestamps[i]), event_file ); - } + //if ( videowriter != NULL ) { + //WriteFrameVideo( images[i], *(timestamps[i]), videowriter ); + //} struct DeltaTimeval delta_time; DELTA_TIMEVAL( delta_time, *(timestamps[i]), start_time, DT_PREC_2 ); @@ -466,20 +467,17 @@ void Event::AddFrame( Image *image, struct timeval timestamp, int score, Image * static char event_file[PATH_MAX]; snprintf( event_file, sizeof(event_file), staticConfig.capture_file_format, path, frames ); - if ( ! ( monitor->GetOptSaveJPEGs() & 3 ) ) { - //if ( monitor->GetOptSaveJPEGs() & 4 ) { - // Only snapshots - //If this is the first frame, we should add a thumbnail to the event directory - if ( frames == 10 || frames == 1 ) { - std::string snapshot_file = std::string(path) + "/snapshot.jpg"; - WriteFrameImage( image, timestamp, snapshot_file.c_str() ); - } - } if ( monitor->GetOptSaveJPEGs() & 1 ) { Debug( 1, "Writing capture frame %d to %s", frames, event_file ); if ( ! WriteFrameImage( image, timestamp, event_file ) ) { Error("Failed to write frame image"); } + } else { + //If this is the first frame, we should add a thumbnail to the event directory + if ( frames == 10 || frames == 1 ) { + std::string snapshot_file = std::string(path) + "/snapshot.jpg"; + WriteFrameImage( image, timestamp, snapshot_file.c_str() ); + } } struct DeltaTimeval delta_time; diff --git a/web/includes/Group.php b/web/includes/Group.php index 9d6d058bb..543665655 100644 --- a/web/includes/Group.php +++ b/web/includes/Group.php @@ -135,6 +135,61 @@ public $defaults = array( return $this->{'MonitorIds'}; } + public static function get_group_dropdown() { + + session_start(); + $selected_group_id = 0; + if ( isset($_REQUEST['groups']) ) { + $selected_group_id = $group_id = $_SESSION['groups'] = $_REQUEST['groups']; + } else if ( isset( $_SESSION['groups'] ) ) { + $selected_group_id = $group_id = $_SESSION['groups']; + } else if ( isset($_REQUEST['filtering']) ) { + unset($_SESSION['groups']); + } + session_write_close(); + + $Groups = array(); + foreach ( Group::find_all( ) as $Group ) { + $Groups[$Group->Id()] = $Group; + } + +# This array is indexed by parent_id +global $children; + $children = array(); + + foreach ( $Groups as $id=>$Group ) { + if ( $Group->ParentId() != null ) { + if ( ! isset( $children[$Group->ParentId()] ) ) + $children[$Group->ParentId()] = array(); + $children[$Group->ParentId()][] = $Group; + } + } + + function get_options( $Group ) { + global $children; + $options = array( $Group->Id() => str_repeat(' ', $Group->depth() ) . $Group->Name() ); + if ( isset($children[$Group->Id()]) ) { + foreach ( $children[$Group->Id()] as $child ) { + $options += get_options( $child ); + } + } + return $options; + } + $group_options = array(); + foreach ( $Groups as $id=>$Group ) { + if ( ! $Group->ParentId() ) { + $group_options += get_options( $Group ); + } + } + return htmlSelect( 'Group[]', $group_options, isset($_SESSION['Group'])?$_SESSION['Group']:null, array( + 'onchange' => 'this.form.submit();', + 'class'=>'chosen', + 'multiple'=>'multiple', + 'data-placeholder'=>'All', + ) ); + + } # end public static function get_group_dropdown + public static function get_group_dropdowns() { # This will end up with the group_id of the deepest selection $group_id = 0; @@ -142,6 +197,8 @@ public $defaults = array( $groups = array(); $parent_group_ids = null; session_start(); + + $group_options = array(0=>'All'); while(1) { $Groups = Group::find_all( array('ParentId'=>$parent_group_ids) ); if ( ! count( $Groups ) ) @@ -161,15 +218,17 @@ public $defaults = array( if ( ! isset( $groups[$depth] ) ) { $groups[$depth] = array(0=>'All'); } +$group_options[$Group->Id()] = str_repeat( ' ', $depth ) . $Group->Name(); $groups[$depth][$Group->Id()] = $Group->Name(); if ( $selected_group_id and ( $selected_group_id == $Group->Id() ) ) $parent_group_ids[] = $Group->Id(); } - echo htmlSelect( 'group'.$depth, $groups[$depth], $selected_group_id, "this.form.submit();" ); + //echo htmlSelect( 'group'.$depth, $groups[$depth], $selected_group_id, "this.form.submit();" ); if ( ! count($parent_group_ids) ) break; $depth += 1; } + echo htmlSelect( 'groups', $group_options, $selected_group_id, 'this.form.submit();' ); session_write_close(); return $group_id; @@ -179,9 +238,17 @@ public $defaults = array( public static function get_group_sql( $group_id ) { $groupSql = ''; if ( $group_id ) { - $MonitorIds = dbFetchAll( 'SELECT MonitorId FROM Groups_Monitors WHERE GroupId=?', 'MonitorId', array($group_id) ); + if ( is_array( $group_id ) ) { + $group_id_sql_part = ' IN ('.implode(',', array_map(function(){return '?';}, $group_id ) ).')'; - $MonitorIds = array_merge( $MonitorIds, dbFetchAll( 'SELECT MonitorId FROM Groups_Monitors WHERE GroupId IN (SELECT Id FROM Groups WHERE ParentId = ?)', 'MonitorId', array($group_id) ) ); + $MonitorIds = dbFetchAll( 'SELECT MonitorId FROM Groups_Monitors WHERE GroupId'.$group_id_sql_part, 'MonitorId', $group_id ); + + $MonitorIds = array_merge( $MonitorIds, dbFetchAll( 'SELECT MonitorId FROM Groups_Monitors WHERE GroupId IN (SELECT Id FROM Groups WHERE ParentId'.$group_id_sql_part.')', 'MonitorId', $group_id ) ); + } else { + $MonitorIds = dbFetchAll( 'SELECT MonitorId FROM Groups_Monitors WHERE GroupId=?', 'MonitorId', array($group_id) ); + + $MonitorIds = array_merge( $MonitorIds, dbFetchAll( 'SELECT MonitorId FROM Groups_Monitors WHERE GroupId IN (SELECT Id FROM Groups WHERE ParentId = ?)', 'MonitorId', array($group_id) ) ); + } $groupSql = " find_in_set( Id, '".implode( ',', $MonitorIds )."' )"; } return $groupSql; diff --git a/web/includes/Server.php b/web/includes/Server.php index fa892f8d9..a6d2b06a5 100644 --- a/web/includes/Server.php +++ b/web/includes/Server.php @@ -23,15 +23,39 @@ class Server { $this->{'Hostname'} = ''; } } - public static function find_all() { - $servers = array(); - $result = dbQuery( 'SELECT * FROM Servers ORDER BY Name'); - $results = $result->fetchALL(PDO::FETCH_CLASS | PDO::FETCH_PROPS_LATE, 'Server' ); - foreach ( $results as $row => $server_obj ) { - $servers[] = $server_obj; - } - return $servers; - } + public static function find_all( $parameters = null, $options = null ) { + $filters = array(); + $sql = 'SELECT * FROM Servers '; + $values = array(); + + if ( $parameters ) { + $fields = array(); + $sql .= 'WHERE '; + foreach ( $parameters as $field => $value ) { + if ( $value == null ) { + $fields[] = $field.' IS NULL'; + } else if ( is_array( $value ) ) { + $func = function(){return '?';}; + $fields[] = $field.' IN ('.implode(',', array_map( $func, $value ) ). ')'; + $values += $value; + + } else { + $fields[] = $field.'=?'; + $values[] = $value; + } + } + $sql .= implode(' AND ', $fields ); + } + if ( $options and isset($options['order']) ) { + $sql .= ' ORDER BY ' . $options['order']; + } + $result = dbQuery($sql, $values); + $results = $result->fetchALL(PDO::FETCH_CLASS | PDO::FETCH_PROPS_LATE, 'Server'); + foreach ( $results as $row => $obj ) { + $filters[] = $obj; + } + return $filters; + } public function Url() { if ( $this->Id() ) { diff --git a/web/includes/control_functions.php b/web/includes/control_functions.php index d5fa06675..bea235668 100644 --- a/web/includes/control_functions.php +++ b/web/includes/control_functions.php @@ -1,994 +1,763 @@ HasFocusSpeed() ) - { - $speed = intval(round($monitor->MinFocusSpeed()+(($monitor->MaxFocusSpeed()-$monitor->MinFocusSpeed())*$factor))); - $ctrlCommand .= " --speed=".$speed; - } - switch( $mode ) - { - case 'Abs' : - case 'Rel' : - { - $step = intval(round($monitor->MinFocusStep()+(($monitor->MaxFocusStep()-$monitor->MinFocusStep())*$factor))); - $ctrlCommand .= " --step=".$step; - break; - } - case 'Con' : - { - if ( $monitor->AutoStopTimeout() ) - { - $slowSpeed = intval(round($monitor->MinFocusSpeed()+(($monitor->MaxFocusSpeed()-$monitor->MinFocusSpeed())*$slow))); - if ( $speed < $slowSpeed ) - { - $ctrlCommand .= " --autostop"; - } - } - break; - } - } - break; - } - case 'zoom' : - { - $factor = $_REQUEST['yge']/100; - if ( $monitor->HasZoomSpeed() ) - { - $speed = intval(round($monitor->MinZoomSpeed()+(($monitor->MaxZoomSpeed()-$monitor->MinZoomSpeed())*$factor))); - $ctrlCommand .= " --speed=".$speed; - } - switch( $mode ) - { - case 'Abs' : - case 'Rel' : - { - $step = intval(round($monitor->MinZoomStep()+(($monitor->MaxZoomStep()-$monitor->MinZoomStep())*$factor))); - $ctrlCommand .= " --step=".$step; - break; - } - case 'Con' : - { - if ( $monitor->AutoStopTimeout() ) - { - $slowSpeed = intval(round($monitor->MinZoomSpeed()+(($monitor->MaxZoomSpeed()-$monitor->MinZoomSpeed())*$slow))); - if ( $speed < $slowSpeed ) - { - $ctrlCommand .= " --autostop"; - } - } - break; - } - } - break; - } - case 'iris' : - { - $factor = $_REQUEST['yge']/100; - if ( $monitor->HasIrisSpeed() ) - { - $speed = intval(round($monitor->MinIrisSpeed()+(($monitor->MaxIrisSpeed()-$monitor->MinIrisSpeed())*$factor))); - $ctrlCommand .= " --speed=".$speed; - } - switch( $mode ) - { - case 'Abs' : - case 'Rel' : - { - $step = intval(round($monitor->MinIrisStep()+(($monitor->MaxIrisStep()-$monitor->MinIrisStep())*$factor))); - $ctrlCommand .= " --step=".$step; - break; - } - } - break; - } - case 'white' : - { - $factor = $_REQUEST['yge']/100; - if ( $monitor->HasWhiteSpeed() ) - { - $speed = intval(round($monitor->MinWhiteSpeed()+(($monitor->MaxWhiteSpeed()-$monitor->MinWhiteSpeed())*$factor))); - $ctrlCommand .= " --speed=".$speed; - } - switch( $mode ) - { - case 'Abs' : - case 'Rel' : - { - $step = intval(round($monitor->MinWhiteStep()+(($monitor->MaxWhiteStep()-$monitor->MinWhiteStep())*$factor))); - $ctrlCommand .= " --step=".$step; - break; - } - } - break; - } - case 'gain' : - { - $factor = $_REQUEST['yge']/100; - if ( $monitor->HasGainSpeed() ) - { - $speed = intval(round($monitor->MinGainSpeed()+(($monitor->MaxGainSpeed()-$monitor->MinGainSpeed())*$factor))); - $ctrlCommand .= " --speed=".$speed; - } - switch( $mode ) - { - case 'Abs' : - case 'Rel' : - { - $step = intval(round($monitor->MinGainStep()+(($monitor->MaxGainStep()-$monitor->MinGainStep())*$factor))); - $ctrlCommand .= " --step=".$step; - break; - } - } - break; - } - case 'move' : - { - $xFactor = empty($_REQUEST['xge'])?0:$_REQUEST['xge']/100; - $yFactor = empty($_REQUEST['yge'])?0:$_REQUEST['yge']/100; - - if ( $monitor->Orientation() != '0' ) - { - $conversions = array( - '90' => array( - 'Up' => 'Left', - 'Down' => 'Right', - 'Left' => 'Down', - 'Right' => 'Up', - 'UpLeft' => 'DownLeft', - 'UpRight' => 'UpLeft', - 'DownLeft' => 'DownRight', - 'DownRight' => 'UpRight', - ), - '180' => array( - 'Up' => 'Down', - 'Down' => 'Up', - 'Left' => 'Right', - 'Right' => 'Left', - 'UpLeft' => 'DownRight', - 'UpRight' => 'DownLeft', - 'DownLeft' => 'UpRight', - 'DownRight' => 'UpLeft', - ), - '270' => array( - 'Up' => 'Right', - 'Down' => 'Left', - 'Left' => 'Up', - 'Right' => 'Down', - 'UpLeft' => 'UpRight', - 'UpRight' => 'DownRight', - 'DownLeft' => 'UpLeft', - 'DownRight' => 'DownLeft', - ), - 'hori' => array( - 'Up' => 'Up', - 'Down' => 'Down', - 'Left' => 'Right', - 'Right' => 'Left', - 'UpLeft' => 'UpRight', - 'UpRight' => 'UpLeft', - 'DownLeft' => 'DownRight', - 'DownRight' => 'DownLeft', - ), - 'vert' => array( - 'Up' => 'Down', - 'Down' => 'Up', - 'Left' => 'Left', - 'Right' => 'Right', - 'UpLeft' => 'DownLeft', - 'UpRight' => 'DownRight', - 'DownLeft' => 'UpLeft', - 'DownRight' => 'UpRight', - ), - ); - $new_dirn = $conversions[$monitor->Orientation()][$dirn]; - $_REQUEST['control'] = preg_replace( "/_$dirn\$/", "_$new_dirn", $_REQUEST['control'] ); - $dirn = $new_dirn; - } - - if ( $monitor->HasPanSpeed() && $xFactor ) - { - if ( $monitor->HasTurboPan() ) - { - if ( $xFactor >= $turbo ) - { - $panSpeed = $monitor->TurboPanSpeed(); - } - else - { - $xFactor = $xFactor/$turbo; - $panSpeed = intval(round($monitor->MinPanSpeed()+(($monitor->MaxPanSpeed()-$monitor->MinPanSpeed())*$xFactor))); - } - } - else - { - $panSpeed = intval(round($monitor->MinPanSpeed()+(($monitor->MaxPanSpeed()-$monitor->MinPanSpeed())*$xFactor))); - } - $ctrlCommand .= " --panspeed=".$panSpeed; - } - if ( $monitor->HasTiltSpeed() && $yFactor ) - { - if ( $monitor->HasTurboTilt() ) - { - if ( $yFactor >= $turbo ) - { - $tiltSpeed = $monitor->TurboTiltSpeed(); - } - else - { - $yFactor = $yFactor/$turbo; - $tiltSpeed = intval(round($monitor->MinTiltSpeed()+(($monitor->MaxTiltSpeed()-$monitor->MinTiltSpeed())*$yFactor))); - } - } - else - { - $tiltSpeed = intval(round($monitor->MinTiltSpeed()+(($monitor->MaxTiltSpeed()-$monitor->MinTiltSpeed())*$yFactor))); - } - $ctrlCommand .= " --tiltspeed=".$tiltSpeed; - } - switch( $mode ) - { - case 'Rel' : - case 'Abs' : - { - if ( preg_match( '/(Left|Right)$/', $dirn ) ) - { - $panStep = intval(round($monitor->MinPanStep()+(($monitor->MaxPanStep()-$monitor->MinPanStep())*$xFactor))); - $ctrlCommand .= " --panstep=".$panStep; - } - if ( preg_match( '/^(Up|Down)/', $dirn ) ) - { - $tiltStep = intval(round($monitor->MinTiltStep()+(($monitor->MaxTiltStep()-$monitor->MinTiltStep())*$yFactor))); - $ctrlCommand .= " --tiltstep=".$tiltStep; - } - break; - } - case 'Con' : - { - if ( $monitor->AutoStopTimeout() ) - { - $slowPanSpeed = intval(round($monitor->MinPanSpeed()+(($monitor->MaxPanSpeed()-$monitor->MinPanSpeed())*$slow))); - $slowTiltSpeed = intval(round($monitor->MinTiltSpeed()+(($monitor->MaxTiltSpeed()-$monitor->MinTiltSpeed())*$slow))); - if ( (!isset($panSpeed) || ($panSpeed < $slowPanSpeed)) && (!isset($tiltSpeed) || ($tiltSpeed < $slowTiltSpeed)) ) - { - $ctrlCommand .= " --autostop"; - } - } - break; - } - } - } - } - } else { - Error("Invalid control parameter: " . $_REQUEST['control'] ); + switch( $command ) { + case 'focus' : + { + $factor = $_REQUEST['yge']/100; + if ( $monitor->HasFocusSpeed() ) { + $speed = intval(round($monitor->MinFocusSpeed()+(($monitor->MaxFocusSpeed()-$monitor->MinFocusSpeed())*$factor))); + $ctrlCommand .= ' --speed='.$speed; } + switch( $mode ) { + case 'Abs' : + case 'Rel' : + { + $step = intval(round($monitor->MinFocusStep()+(($monitor->MaxFocusStep()-$monitor->MinFocusStep())*$factor))); + $ctrlCommand .= ' --step='.$step; + break; + } + case 'Con' : + { + if ( $monitor->AutoStopTimeout() ) { + $slowSpeed = intval(round($monitor->MinFocusSpeed()+(($monitor->MaxFocusSpeed()-$monitor->MinFocusSpeed())*$slow))); + if ( $speed < $slowSpeed ) { + $ctrlCommand .= ' --autostop'; + } + } + break; + } + } + break; + } + case 'zoom' : + $factor = $_REQUEST['yge']/100; + if ( $monitor->HasZoomSpeed() ) { + $speed = intval(round($monitor->MinZoomSpeed()+(($monitor->MaxZoomSpeed()-$monitor->MinZoomSpeed())*$factor))); + $ctrlCommand .= ' --speed='.$speed; + } + switch( $mode ) { + case 'Abs' : + case 'Rel' : + $step = intval(round($monitor->MinZoomStep()+(($monitor->MaxZoomStep()-$monitor->MinZoomStep())*$factor))); + $ctrlCommand .= ' --step='.$step; + break; + case 'Con' : + if ( $monitor->AutoStopTimeout() ) { + $slowSpeed = intval(round($monitor->MinZoomSpeed()+(($monitor->MaxZoomSpeed()-$monitor->MinZoomSpeed())*$slow))); + if ( $speed < $slowSpeed ) { + $ctrlCommand .= ' --autostop'; + } + } + break; + } + break; + case 'iris' : + $factor = $_REQUEST['yge']/100; + if ( $monitor->HasIrisSpeed() ) { + $speed = intval(round($monitor->MinIrisSpeed()+(($monitor->MaxIrisSpeed()-$monitor->MinIrisSpeed())*$factor))); + $ctrlCommand .= ' --speed='.$speed; + } + switch( $mode ) { + case 'Abs' : + case 'Rel' : + $step = intval(round($monitor->MinIrisStep()+(($monitor->MaxIrisStep()-$monitor->MinIrisStep())*$factor))); + $ctrlCommand .= ' --step='.$step; + break; + } + break; + case 'white' : + $factor = $_REQUEST['yge']/100; + if ( $monitor->HasWhiteSpeed() ) { + $speed = intval(round($monitor->MinWhiteSpeed()+(($monitor->MaxWhiteSpeed()-$monitor->MinWhiteSpeed())*$factor))); + $ctrlCommand .= ' --speed='.$speed; + } + switch( $mode ) { + case 'Abs' : + case 'Rel' : + $step = intval(round($monitor->MinWhiteStep()+(($monitor->MaxWhiteStep()-$monitor->MinWhiteStep())*$factor))); + $ctrlCommand .= ' --step='.$step; + break; + } + break; + case 'gain' : + $factor = $_REQUEST['yge']/100; + if ( $monitor->HasGainSpeed() ) { + $speed = intval(round($monitor->MinGainSpeed()+(($monitor->MaxGainSpeed()-$monitor->MinGainSpeed())*$factor))); + $ctrlCommand .= ' --speed='.$speed; + } + switch( $mode ) { + case 'Abs' : + case 'Rel' : + $step = intval(round($monitor->MinGainStep()+(($monitor->MaxGainStep()-$monitor->MinGainStep())*$factor))); + $ctrlCommand .= ' --step='.$step; + break; + } + break; + case 'move' : + $xFactor = empty($_REQUEST['xge'])?0:$_REQUEST['xge']/100; + $yFactor = empty($_REQUEST['yge'])?0:$_REQUEST['yge']/100; + + if ( $monitor->Orientation() != '0' ) { + $conversions = array( + '90' => array( + 'Up' => 'Left', + 'Down' => 'Right', + 'Left' => 'Down', + 'Right' => 'Up', + 'UpLeft' => 'DownLeft', + 'UpRight' => 'UpLeft', + 'DownLeft' => 'DownRight', + 'DownRight' => 'UpRight', + ), + '180' => array( + 'Up' => 'Down', + 'Down' => 'Up', + 'Left' => 'Right', + 'Right' => 'Left', + 'UpLeft' => 'DownRight', + 'UpRight' => 'DownLeft', + 'DownLeft' => 'UpRight', + 'DownRight' => 'UpLeft', + ), + '270' => array( + 'Up' => 'Right', + 'Down' => 'Left', + 'Left' => 'Up', + 'Right' => 'Down', + 'UpLeft' => 'UpRight', + 'UpRight' => 'DownRight', + 'DownLeft' => 'UpLeft', + 'DownRight' => 'DownLeft', + ), + 'hori' => array( + 'Up' => 'Up', + 'Down' => 'Down', + 'Left' => 'Right', + 'Right' => 'Left', + 'UpLeft' => 'UpRight', + 'UpRight' => 'UpLeft', + 'DownLeft' => 'DownRight', + 'DownRight' => 'DownLeft', + ), + 'vert' => array( + 'Up' => 'Down', + 'Down' => 'Up', + 'Left' => 'Left', + 'Right' => 'Right', + 'UpLeft' => 'DownLeft', + 'UpRight' => 'DownRight', + 'DownLeft' => 'UpLeft', + 'DownRight' => 'UpRight', + ), + ); + $new_dirn = $conversions[$monitor->Orientation()][$dirn]; + $_REQUEST['control'] = preg_replace( "/_$dirn\$/", "_$new_dirn", $_REQUEST['control'] ); + $dirn = $new_dirn; + } + + if ( $monitor->HasPanSpeed() && $xFactor ) { + if ( $monitor->HasTurboPan() ) { + if ( $xFactor >= $turbo ) { + $panSpeed = $monitor->TurboPanSpeed(); + } else { + $xFactor = $xFactor/$turbo; + $panSpeed = intval(round($monitor->MinPanSpeed()+(($monitor->MaxPanSpeed()-$monitor->MinPanSpeed())*$xFactor))); + } + } else { + $panSpeed = intval(round($monitor->MinPanSpeed()+(($monitor->MaxPanSpeed()-$monitor->MinPanSpeed())*$xFactor))); + } + $ctrlCommand .= ' --panspeed='.$panSpeed; + } + if ( $monitor->HasTiltSpeed() && $yFactor ) { + if ( $monitor->HasTurboTilt() ) { + if ( $yFactor >= $turbo ) { + $tiltSpeed = $monitor->TurboTiltSpeed(); + } else { + $yFactor = $yFactor/$turbo; + $tiltSpeed = intval(round($monitor->MinTiltSpeed()+(($monitor->MaxTiltSpeed()-$monitor->MinTiltSpeed())*$yFactor))); + } + } else { + $tiltSpeed = intval(round($monitor->MinTiltSpeed()+(($monitor->MaxTiltSpeed()-$monitor->MinTiltSpeed())*$yFactor))); + } + $ctrlCommand .= ' --tiltspeed='.$tiltSpeed; + } + switch( $mode ) { + case 'Rel' : + case 'Abs' : + if ( preg_match( '/(Left|Right)$/', $dirn ) ) { + $panStep = intval(round($monitor->MinPanStep()+(($monitor->MaxPanStep()-$monitor->MinPanStep())*$xFactor))); + $ctrlCommand .= ' --panstep='.$panStep; + } + if ( preg_match( '/^(Up|Down)/', $dirn ) ) { + $tiltStep = intval(round($monitor->MinTiltStep()+(($monitor->MaxTiltStep()-$monitor->MinTiltStep())*$yFactor))); + $ctrlCommand .= ' --tiltstep='.$tiltStep; + } + break; + case 'Con' : + if ( $monitor->AutoStopTimeout() ) { + $slowPanSpeed = intval(round($monitor->MinPanSpeed()+(($monitor->MaxPanSpeed()-$monitor->MinPanSpeed())*$slow))); + $slowTiltSpeed = intval(round($monitor->MinTiltSpeed()+(($monitor->MaxTiltSpeed()-$monitor->MinTiltSpeed())*$slow))); + if ( (!isset($panSpeed) || ($panSpeed < $slowPanSpeed)) && (!isset($tiltSpeed) || ($tiltSpeed < $slowTiltSpeed)) ) { + $ctrlCommand .= ' --autostop'; + } + } + break; + } + } + } else { + Error('Invalid control parameter: ' . $_REQUEST['control'] ); } - elseif ( isset($_REQUEST['x']) && isset($_REQUEST['y']) ) - { - if ( $_REQUEST['control'] == "moveMap" ) - { - $x = deScale( $_REQUEST['x'], $_REQUEST['scale'] ); - $y = deScale( $_REQUEST['y'], $_REQUEST['scale'] ); - switch ( $monitor->Orientation() ) - { - case '0' : - case '180' : - case 'hori' : - case 'vert' : - $width = $monitor->Width(); - $height = $monitor->Height(); - break; - case '90' : - case '270' : - $width = $monitor->Height(); - $height = $monitor->Width(); - break; + } elseif ( isset($_REQUEST['x']) && isset($_REQUEST['y']) ) { + if ( $_REQUEST['control'] == 'moveMap' ) { + $x = deScale( $_REQUEST['x'], $_REQUEST['scale'] ); + $y = deScale( $_REQUEST['y'], $_REQUEST['scale'] ); + switch ( $monitor->Orientation() ) { + case '0' : + case '180' : + case 'hori' : + case 'vert' : + $width = $monitor->Width(); + $height = $monitor->Height(); + break; + case '90' : + case '270' : + $width = $monitor->Height(); + $height = $monitor->Width(); + break; + } + switch ( $monitor->Orientation() ) { + case '90' : + $tempY = $y; + $y = $height - $x; + $x = $tempY; + break; + case '180' : + $x = $width - $x; + $y = $height - $y; + break; + case '270' : + $tempX = $x; + $x = $width - $y; + $y = $tempX; + break; + case 'hori' : + $x = $width - $x; + break; + case 'vert' : + $y = $height - $y; + break; + } + //$ctrlCommand .= " --xcoord=$x --ycoord=$y --width=$width --height=$height"; + $ctrlCommand .= " --xcoord=$x --ycoord=$y"; + } elseif ( $_REQUEST['control'] == 'movePseudoMap' ) { + $x = deScale( $_REQUEST['x'], $_REQUEST['scale'] ); + $y = deScale( $_REQUEST['y'], $_REQUEST['scale'] ); + + $halfWidth = $monitor->Width() / 2; + $halfHeight = $monitor->Height() / 2; + $xFactor = ($x - $halfWidth)/$halfWidth; + $yFactor = ($y - $halfHeight)/$halfHeight; + + switch ( $monitor->Orientation() ) { + case '90' : + $tempYFactor = $y; + $yFactor = -$xFactor; + $xFactor = $tempYFactor; + break; + case '180' : + $xFactor = -$xFactor; + $yFactor = -$yFactor; + break; + case '270' : + $tempXFactor = $x; + $xFactor = -$yFactor; + $yFactor = $tempXFactor; + break; + case 'hori' : + $xFactor = -$xFactor; + break; + case 'vert' : + $yFactor = -$yFactor; + break; + } + + $turbo = 0.9; // Threshold for turbo speed + $blind = 0.1; // Threshold for blind spot + + $panControl = ''; + $tiltControl = ''; + if ( $xFactor > $blind ) { + $panControl = 'Right'; + } elseif ( $xFactor < -$blind ) { + $panControl = 'Left'; + } + if ( $yFactor > $blind ) { + $tiltControl = 'Down'; + } elseif ( $yFactor < -$blind ) { + $tiltControl = 'Up'; + } + + $dirn = $tiltControl.$panControl; + if ( !$dirn ) { + // No command, probably in blind spot in middle + $_REQUEST['control'] = 'null'; + return( false ); + } else { + $_REQUEST['control'] = 'moveRel'.$dirn; + $xFactor = abs($xFactor); + $yFactor = abs($yFactor); + + if ( $monitor->HasPanSpeed() && $xFactor ) { + if ( $monitor->HasTurboPan() ) { + if ( $xFactor >= $turbo ) { + $panSpeed = $monitor->TurboPanSpeed(); + } else { + $xFactor = $xFactor/$turbo; + $panSpeed = intval(round($monitor->MinPanSpeed()+(($monitor->MaxPanSpeed()-$monitor->MinPanSpeed())*$xFactor))); } - switch ( $monitor->Orientation() ) - { - case '90' : - $tempY = $y; - $y = $height - $x; - $x = $tempY; - break; - case '180' : - $x = $width - $x; - $y = $height - $y; - break; - case '270' : - $tempX = $x; - $x = $width - $y; - $y = $tempX; - break; - case 'hori' : - $x = $width - $x; - break; - case 'vert' : - $y = $height - $y; - break; - } - //$ctrlCommand .= " --xcoord=$x --ycoord=$y --width=$width --height=$height"; - $ctrlCommand .= " --xcoord=$x --ycoord=$y"; + } else { + $panSpeed = intval(round($monitor->MinPanSpeed()+(($monitor->MaxPanSpeed()-$monitor->MinPanSpeed())*$xFactor))); + } } - elseif ( $_REQUEST['control'] == "movePseudoMap" ) - { - $x = deScale( $_REQUEST['x'], $_REQUEST['scale'] ); - $y = deScale( $_REQUEST['y'], $_REQUEST['scale'] ); - - $halfWidth = $monitor->Width() / 2; - $halfHeight = $monitor->Height() / 2; - $xFactor = ($x - $halfWidth)/$halfWidth; - $yFactor = ($y - $halfHeight)/$halfHeight; - - switch ( $monitor->Orientation() ) - { - case '90' : - $tempYFactor = $y; - $yFactor = -$xFactor; - $xFactor = $tempYFactor; - break; - case '180' : - $xFactor = -$xFactor; - $yFactor = -$yFactor; - break; - case '270' : - $tempXFactor = $x; - $xFactor = -$yFactor; - $yFactor = $tempXFactor; - break; - case 'hori' : - $xFactor = -$xFactor; - break; - case 'vert' : - $yFactor = -$yFactor; - break; - } - - $turbo = 0.9; // Threshold for turbo speed - $blind = 0.1; // Threshold for blind spot - - $panControl = ''; - $tiltControl = ''; - if ( $xFactor > $blind ) - { - $panControl = 'Right'; - } - elseif ( $xFactor < -$blind ) - { - $panControl = 'Left'; - } - if ( $yFactor > $blind ) - { - $tiltControl = 'Down'; - } - elseif ( $yFactor < -$blind ) - { - $tiltControl = 'Up'; - } - - $dirn = $tiltControl.$panControl; - if ( !$dirn ) - { - // No command, probably in blind spot in middle - $_REQUEST['control'] = 'null'; - return( false ); - } - else - { - $_REQUEST['control'] = 'moveRel'.$dirn; - $xFactor = abs($xFactor); - $yFactor = abs($yFactor); - - if ( $monitor->HasPanSpeed() && $xFactor ) - { - if ( $monitor->HasTurboPan() ) - { - if ( $xFactor >= $turbo ) - { - $panSpeed = $monitor->TurboPanSpeed(); - } - else - { - $xFactor = $xFactor/$turbo; - $panSpeed = intval(round($monitor->MinPanSpeed()+(($monitor->MaxPanSpeed()-$monitor->MinPanSpeed())*$xFactor))); - } - } - else - { - $panSpeed = intval(round($monitor->MinPanSpeed()+(($monitor->MaxPanSpeed()-$monitor->MinPanSpeed())*$xFactor))); - } - } - if ( $monitor->HasTiltSpeed() && $yFactor ) - { - if ( $monitor->HasTurboTilt() ) - { - if ( $yFactor >= $turbo ) - { - $tiltSpeed = $monitor->TurboTiltSpeed(); - } - else - { - $yFactor = $yFactor/$turbo; - $tiltSpeed = intval(round($monitor->MinTiltSpeed()+(($monitor->MaxTiltSpeed()-$monitor->MinTiltSpeed())*$yFactor))); - } - } - else - { - $tiltSpeed = intval(round($monitor->MinTiltSpeed()+(($monitor->MaxTiltSpeed()-$monitor->MinTiltSpeed())*$yFactor))); - } - } - if ( preg_match( '/(Left|Right)$/', $dirn ) ) - { - $panStep = intval(round($monitor->MinPanStep()+(($monitor->MaxPanStep()-$monitor->MinPanStep())*$xFactor))); - $ctrlCommand .= " --panstep=".$panStep." --panspeed=".$panSpeed; - } - if ( preg_match( '/^(Up|Down)/', $dirn ) ) - { - $tiltStep = intval(round($monitor->MinTiltStep()+(($monitor->MaxTiltStep()-$monitor->MinTiltStep())*$yFactor))); - $ctrlCommand .= " --tiltstep=".$tiltStep." --tiltspeed=".$tiltSpeed; - } + if ( $monitor->HasTiltSpeed() && $yFactor ) { + if ( $monitor->HasTurboTilt() ) { + if ( $yFactor >= $turbo ) { + $tiltSpeed = $monitor->TurboTiltSpeed(); + } else { + $yFactor = $yFactor/$turbo; + $tiltSpeed = intval(round($monitor->MinTiltSpeed()+(($monitor->MaxTiltSpeed()-$monitor->MinTiltSpeed())*$yFactor))); } + } else { + $tiltSpeed = intval(round($monitor->MinTiltSpeed()+(($monitor->MaxTiltSpeed()-$monitor->MinTiltSpeed())*$yFactor))); + } } - elseif ( $_REQUEST['control'] == "moveConMap" ) - { - $x = deScale( $_REQUEST['x'], $_REQUEST['scale'] ); - $y = deScale( $_REQUEST['y'], $_REQUEST['scale'] ); - - $halfWidth = $monitor->Width() / 2; - $halfHeight = $monitor->Height() / 2; - $xFactor = ($x - $halfWidth)/$halfWidth; - $yFactor = ($y - $halfHeight)/$halfHeight; - - switch ( $monitor->Orientation() ) - { - case '90' : - $tempYFactor = $y; - $yFactor = -$xFactor; - $xFactor = $tempYFactor; - break; - case '180' : - $xFactor = -$xFactor; - $yFactor = -$yFactor; - break; - case '270' : - $tempXFactor = $x; - $xFactor = -$yFactor; - $yFactor = $tempXFactor; - break; - case 'hori' : - $xFactor = -$xFactor; - break; - case 'vert' : - $yFactor = -$yFactor; - break; - } - - $slow = 0.9; // Threshold for slow speed/timeouts - $turbo = 0.9; // Threshold for turbo speed - $blind = 0.1; // Threshold for blind spot - - $panControl = ''; - $tiltControl = ''; - if ( $xFactor > $blind ) - { - $panControl = 'Right'; - } - elseif ( $xFactor < -$blind ) - { - $panControl = 'Left'; - } - if ( $yFactor > $blind ) - { - $tiltControl = 'Down'; - } - elseif ( $yFactor < -$blind ) - { - $tiltControl = 'Up'; - } - - $dirn = $tiltControl.$panControl; - if ( !$dirn ) - { - // No command, probably in blind spot in middle - $_REQUEST['control'] = 'moveStop'; - } - else - { - $_REQUEST['control'] = 'moveCon'.$dirn; - $xFactor = abs($xFactor); - $yFactor = abs($yFactor); - - if ( $monitor->HasPanSpeed() && $xFactor ) - { - if ( $monitor->HasTurboPan() ) - { - if ( $xFactor >= $turbo ) - { - $panSpeed = $monitor->TurboPanSpeed(); - } - else - { - $xFactor = $xFactor/$turbo; - $panSpeed = intval(round($monitor->MinPanSpeed()+(($monitor->MaxPanSpeed()-$monitor->MinPanSpeed())*$xFactor))); - } - } - else - { - $panSpeed = intval(round($monitor->MinPanSpeed()+(($monitor->MaxPanSpeed()-$monitor->MinPanSpeed())*$xFactor))); - } - } - if ( $monitor->HasTiltSpeed() && $yFactor ) - { - if ( $monitor->HasTurboTilt() ) - { - if ( $yFactor >= $turbo ) - { - $tiltSpeed = $monitor->TurboTiltSpeed(); - } - else - { - $yFactor = $yFactor/$turbo; - $tiltSpeed = intval(round($monitor->MinTiltSpeed()+(($monitor->MaxTiltSpeed()-$monitor->MinTiltSpeed())*$yFactor))); - } - } - else - { - $tiltSpeed = intval(round($monitor->MinTiltSpeed()+(($monitor->MaxTiltSpeed()-$monitor->MinTiltSpeed())*$yFactor))); - } - } - if ( preg_match( '/(Left|Right)$/', $dirn ) ) - { - $ctrlCommand .= " --panspeed=".$panSpeed; - } - if ( preg_match( '/^(Up|Down)/', $dirn ) ) - { - $ctrlCommand .= " --tiltspeed=".$tiltSpeed; - } - if ( $monitor->AutoStopTimeout() ) - { - $slowPanSpeed = intval(round($monitor->MinPanSpeed()+(($monitor->MaxPanSpeed()-$monitor->MinPanSpeed())*$slow))); - $slowTiltSpeed = intval(round($monitor->MinTiltSpeed()+(($monitor->MaxTiltSpeed()-$monitor->MinTiltSpeed())*$slow))); - if ( (!isset($panSpeed) || ($panSpeed < $slowPanSpeed)) && (!isset($tiltSpeed) || ($tiltSpeed < $slowTiltSpeed)) ) - { - $ctrlCommand .= " --autostop"; - } - } - } + if ( preg_match( '/(Left|Right)$/', $dirn ) ) { + $panStep = intval(round($monitor->MinPanStep()+(($monitor->MaxPanStep()-$monitor->MinPanStep())*$xFactor))); + $ctrlCommand .= ' --panstep='.$panStep.' --panspeed='.$panSpeed; } - else - { - $slow = 0.9; // Threshold for slow speed/timeouts - $turbo = 0.9; // Threshold for turbo speed - $long_y = 48; - $short_x = 32; - $short_y = 32; - - if ( preg_match( '/^([a-z]+)([A-Z][a-z]+)([A-Z][a-z]+)$/', $_REQUEST['control'], $matches ) ) - { - $command = $matches[1]; - $mode = $matches[2]; - $dirn = $matches[3]; - - switch( $command ) - { - case 'focus' : - { - switch( $dirn ) - { - case 'Near' : - { - $factor = ($long_y-($y+1))/$long_y; - break; - } - case 'Far' : - { - $factor = ($y+1)/$long_y; - break; - } - } - if ( $monitor->HasFocusSpeed() ) - { - $speed = intval(round($monitor->MinFocusSpeed()+(($monitor->MaxFocusSpeed()-$monitor->MinFocusSpeed())*$factor))); - $ctrlCommand .= " --speed=".$speed; - } - switch( $mode ) - { - case 'Abs' : - case 'Rel' : - { - $step = intval(round($monitor->MinFocusStep()+(($monitor->MaxFocusStep()-$monitor->MinFocusStep())*$factor))); - $ctrlCommand .= " --step=".$step; - break; - } - case 'Con' : - { - if ( $monitor->AutoStopTimeout() ) - { - $slowSpeed = intval(round($monitor->MinFocusSpeed()+(($monitor->MaxFocusSpeed()-$monitor->MinFocusSpeed())*$slow))); - if ( $speed < $slowSpeed ) - { - $ctrlCommand .= " --autostop"; - } - } - break; - } - } - break; - } - case 'zoom' : - { - switch( $dirn ) - { - case 'Tele' : - { - $factor = ($long_y-($y+1))/$long_y; - break; - } - case 'Wide' : - { - $factor = ($y+1)/$long_y; - break; - } - } - if ( $monitor->HasZoomSpeed() ) - { - $speed = intval(round($monitor->MinZoomSpeed()+(($monitor->MaxZoomSpeed()-$monitor->MinZoomSpeed())*$factor))); - $ctrlCommand .= " --speed=".$speed; - } - switch( $mode ) - { - case 'Abs' : - case 'Rel' : - { - $step = intval(round($monitor->MinZoomStep()+(($monitor->MaxZoomStep()-$monitor->MinZoomStep())*$factor))); - $ctrlCommand .= " --step=".$step; - break; - } - case 'Con' : - { - if ( $monitor->AutoStopTimeout() ) - { - $slowSpeed = intval(round($monitor->MinZoomSpeed()+(($monitor->MaxZoomSpeed()-$monitor->MinZoomSpeed())*$slow))); - if ( $speed < $slowSpeed ) - { - $ctrlCommand .= " --autostop"; - } - } - break; - } - } - break; - } - case 'iris' : - { - switch( $dirn ) - { - case 'Open' : - { - $factor = ($long_y-($y+1))/$long_y; - break; - } - case 'Close' : - { - $factor = ($y+1)/$long_y; - break; - } - } - if ( $monitor->HasIrisSpeed() ) - { - $speed = intval(round($monitor->MinIrisSpeed()+(($monitor->MaxIrisSpeed()-$monitor->MinIrisSpeed())*$factor))); - $ctrlCommand .= " --speed=".$speed; - } - switch( $mode ) - { - case 'Abs' : - case 'Rel' : - { - $step = intval(round($monitor->MinIrisStep()+(($monitor->MaxIrisStep()-$monitor->MinIrisStep())*$factor))); - $ctrlCommand .= " --step=".$step; - break; - } - } - break; - } - case 'white' : - { - switch( $dirn ) - { - case 'In' : - { - $factor = ($long_y-($y+1))/$long_y; - break; - } - case 'Out' : - { - $factor = ($y+1)/$long_y; - break; - } - } - if ( $monitor->HasWhiteSpeed() ) - { - $speed = intval(round($monitor->MinWhiteSpeed()+(($monitor->MaxWhiteSpeed()-$monitor->MinWhiteSpeed())*$factor))); - $ctrlCommand .= " --speed=".$speed; - } - switch( $mode ) - { - case 'Abs' : - case 'Rel' : - { - $step = intval(round($monitor->MinWhiteStep()+(($monitor->MaxWhiteStep()-$monitor->MinWhiteStep())*$factor))); - $ctrlCommand .= " --step=".$step; - break; - } - } - break; - } - case 'gain' : - { - switch( $dirn ) - { - case 'Up' : - { - $factor = ($long_y-($y+1))/$long_y; - break; - } - case 'Down' : - { - $factor = ($y+1)/$long_y; - break; - } - } - if ( $monitor->HasGainSpeed() ) - { - $speed = intval(round($monitor->MinGainSpeed()+(($monitor->MaxGainSpeed()-$monitor->MinGainSpeed())*$factor))); - $ctrlCommand .= " --speed=".$speed; - } - switch( $mode ) - { - case 'Abs' : - case 'Rel' : - { - $step = intval(round($monitor->MinGainStep()+(($monitor->MaxGainStep()-$monitor->MinGainStep())*$factor))); - $ctrlCommand .= " --step=".$step; - break; - } - } - break; - } - case 'move' : - { - $xFactor = 0; - $yFactor = 0; - - if ( preg_match( '/^Up/', $dirn ) ) - { - $yFactor = ($short_y-($y+1))/$short_y; - } - elseif ( preg_match( '/^Down/', $dirn ) ) - { - $yFactor = ($y+1)/$short_y; - } - if ( preg_match( '/Left$/', $dirn ) ) - { - $xFactor = ($short_x-($x+1))/$short_x; - } - elseif ( preg_match( '/Right$/', $dirn ) ) - { - $xFactor = ($x+1)/$short_x; - } - - if ( $monitor->Orientation() != '0' ) - { - $conversions = array( - '90' => array( - 'Up' => 'Left', - 'Down' => 'Right', - 'Left' => 'Down', - 'Right' => 'Up', - 'UpLeft' => 'DownLeft', - 'UpRight' => 'UpLeft', - 'DownLeft' => 'DownRight', - 'DownRight' => 'UpRight', - ), - '180' => array( - 'Up' => 'Down', - 'Down' => 'Up', - 'Left' => 'Right', - 'Right' => 'Left', - 'UpLeft' => 'DownRight', - 'UpRight' => 'DownLeft', - 'DownLeft' => 'UpRight', - 'DownRight' => 'UpLeft', - ), - '270' => array( - 'Up' => 'Right', - 'Down' => 'Left', - 'Left' => 'Up', - 'Right' => 'Down', - 'UpLeft' => 'UpRight', - 'UpRight' => 'DownRight', - 'DownLeft' => 'UpLeft', - 'DownRight' => 'DownLeft', - ), - 'hori' => array( - 'Up' => 'Up', - 'Down' => 'Down', - 'Left' => 'Right', - 'Right' => 'Left', - 'UpLeft' => 'UpRight', - 'UpRight' => 'UpLeft', - 'DownLeft' => 'DownRight', - 'DownRight' => 'DownLeft', - ), - 'vert' => array( - 'Up' => 'Down', - 'Down' => 'Up', - 'Left' => 'Left', - 'Right' => 'Right', - 'UpLeft' => 'DownLeft', - 'UpRight' => 'DownRight', - 'DownLeft' => 'UpLeft', - 'DownRight' => 'UpRight', - ), - ); - $new_dirn = $conversions[$monitor->Orientation()][$dirn]; - $_REQUEST['control'] = preg_replace( "/_$dirn\$/", "_$new_dirn", $_REQUEST['control'] ); - $dirn = $new_dirn; - } - - if ( $monitor->HasPanSpeed() && $xFactor ) - { - if ( $monitor->HasTurboPan() ) - { - if ( $xFactor >= $turbo ) - { - $panSpeed = $monitor->TurboPanSpeed(); - } - else - { - $xFactor = $xFactor/$turbo; - $panSpeed = intval(round($monitor->MinPanSpeed()+(($monitor->MaxPanSpeed()-$monitor->MinPanSpeed())*$xFactor))); - } - } - else - { - $panSpeed = intval(round($monitor->MinPanSpeed()+(($monitor->MaxPanSpeed()-$monitor->MinPanSpeed())*$xFactor))); - } - $ctrlCommand .= " --panspeed=".$panSpeed; - } - if ( $monitor->HasTiltSpeed() && $yFactor ) - { - if ( $monitor->HasTurboTilt() ) - { - if ( $yFactor >= $turbo ) - { - $tiltSpeed = $monitor->TurboTiltSpeed(); - } - else - { - $yFactor = $yFactor/$turbo; - $tiltSpeed = intval(round($monitor->MinTiltSpeed()+(($monitor->MaxTiltSpeed()-$monitor->MinTiltSpeed())*$yFactor))); - } - } - else - { - $tiltSpeed = intval(round($monitor->MinTiltSpeed()+(($monitor->MaxTiltSpeed()-$monitor->MinTiltSpeed())*$yFactor))); - } - $ctrlCommand .= " --tiltspeed=".$tiltSpeed; - } - switch( $mode ) - { - case 'Rel' : - case 'Abs' : - { - if ( preg_match( '/(Left|Right)$/', $dirn ) ) - { - $panStep = intval(round($monitor->MinPanStep()+(($monitor->MaxPanStep()-$monitor->MinPanStep())*$xFactor))); - $ctrlCommand .= " --panstep=".$panStep; - } - if ( preg_match( '/^(Up|Down)/', $dirn ) ) - { - $tiltStep = intval(round($monitor->MinTiltStep()+(($monitor->MaxTiltStep()-$monitor->MinTiltStep())*$yFactor))); - $ctrlCommand .= " --tiltstep=".$tiltStep; - } - break; - } - case 'Con' : - { - if ( $monitor->AutoStopTimeout() ) - { - $slowPanSpeed = intval(round($monitor->MinPanSpeed()+(($monitor->MaxPanSpeed()-$monitor->MinPanSpeed())*$slow))); - $slowTiltSpeed = intval(round($monitor->MinTiltSpeed()+(($monitor->MaxTiltSpeed()-$monitor->MinTiltSpeed())*$slow))); - if ( (!isset($panSpeed) || ($panSpeed < $slowPanSpeed)) && (!isset($tiltSpeed) || ($tiltSpeed < $slowTiltSpeed)) ) - { - $ctrlCommand .= " --autostop"; - } - } - break; - } - } - } - } - } + if ( preg_match( '/^(Up|Down)/', $dirn ) ) { + $tiltStep = intval(round($monitor->MinTiltStep()+(($monitor->MaxTiltStep()-$monitor->MinTiltStep())*$yFactor))); + $ctrlCommand .= ' --tiltstep='.$tiltStep.' --tiltspeed='.$tiltSpeed; } + } + } elseif ( $_REQUEST['control'] == 'moveConMap' ) { + $x = deScale( $_REQUEST['x'], $_REQUEST['scale'] ); + $y = deScale( $_REQUEST['y'], $_REQUEST['scale'] ); + + $halfWidth = $monitor->Width() / 2; + $halfHeight = $monitor->Height() / 2; + $xFactor = ($x - $halfWidth)/$halfWidth; + $yFactor = ($y - $halfHeight)/$halfHeight; + + switch ( $monitor->Orientation() ) { + case '90' : + $tempYFactor = $y; + $yFactor = -$xFactor; + $xFactor = $tempYFactor; + break; + case '180' : + $xFactor = -$xFactor; + $yFactor = -$yFactor; + break; + case '270' : + $tempXFactor = $x; + $xFactor = -$yFactor; + $yFactor = $tempXFactor; + break; + case 'hori' : + $xFactor = -$xFactor; + break; + case 'vert' : + $yFactor = -$yFactor; + break; + } + + $slow = 0.9; // Threshold for slow speed/timeouts + $turbo = 0.9; // Threshold for turbo speed + $blind = 0.1; // Threshold for blind spot + + $panControl = ''; + $tiltControl = ''; + if ( $xFactor > $blind ) { + $panControl = 'Right'; + } elseif ( $xFactor < -$blind ) { + $panControl = 'Left'; + } + if ( $yFactor > $blind ) { + $tiltControl = 'Down'; + } elseif ( $yFactor < -$blind ) { + $tiltControl = 'Up'; + } + + $dirn = $tiltControl.$panControl; + if ( !$dirn ) { + // No command, probably in blind spot in middle + $_REQUEST['control'] = 'moveStop'; + } else { + $_REQUEST['control'] = 'moveCon'.$dirn; + $xFactor = abs($xFactor); + $yFactor = abs($yFactor); + + if ( $monitor->HasPanSpeed() && $xFactor ) { + if ( $monitor->HasTurboPan() ) { + if ( $xFactor >= $turbo ) { + $panSpeed = $monitor->TurboPanSpeed(); + } else { + $xFactor = $xFactor/$turbo; + $panSpeed = intval(round($monitor->MinPanSpeed()+(($monitor->MaxPanSpeed()-$monitor->MinPanSpeed())*$xFactor))); + } + } else { + $panSpeed = intval(round($monitor->MinPanSpeed()+(($monitor->MaxPanSpeed()-$monitor->MinPanSpeed())*$xFactor))); + } + } + if ( $monitor->HasTiltSpeed() && $yFactor ) { + if ( $monitor->HasTurboTilt() ) { + if ( $yFactor >= $turbo ) { + $tiltSpeed = $monitor->TurboTiltSpeed(); + } else { + $yFactor = $yFactor/$turbo; + $tiltSpeed = intval(round($monitor->MinTiltSpeed()+(($monitor->MaxTiltSpeed()-$monitor->MinTiltSpeed())*$yFactor))); + } + } else { + $tiltSpeed = intval(round($monitor->MinTiltSpeed()+(($monitor->MaxTiltSpeed()-$monitor->MinTiltSpeed())*$yFactor))); + } + } + if ( preg_match( '/(Left|Right)$/', $dirn ) ) { + $ctrlCommand .= ' --panspeed='.$panSpeed; + } + if ( preg_match( '/^(Up|Down)/', $dirn ) ) { + $ctrlCommand .= ' --tiltspeed='.$tiltSpeed; + } + if ( $monitor->AutoStopTimeout() ) { + $slowPanSpeed = intval(round($monitor->MinPanSpeed()+(($monitor->MaxPanSpeed()-$monitor->MinPanSpeed())*$slow))); + $slowTiltSpeed = intval(round($monitor->MinTiltSpeed()+(($monitor->MaxTiltSpeed()-$monitor->MinTiltSpeed())*$slow))); + if ( (!isset($panSpeed) || ($panSpeed < $slowPanSpeed)) && (!isset($tiltSpeed) || ($tiltSpeed < $slowTiltSpeed)) ) { + $ctrlCommand .= ' --autostop'; + } + } + } + } else { + $slow = 0.9; // Threshold for slow speed/timeouts + $turbo = 0.9; // Threshold for turbo speed + $long_y = 48; + $short_x = 32; + $short_y = 32; + + if ( preg_match( '/^([a-z]+)([A-Z][a-z]+)([A-Z][a-z]+)$/', $_REQUEST['control'], $matches ) ) { + $command = $matches[1]; + $mode = $matches[2]; + $dirn = $matches[3]; + + switch( $command ) { + case 'focus' : + switch( $dirn ) { + case 'Near' : + $factor = ($long_y-($y+1))/$long_y; + break; + case 'Far' : + $factor = ($y+1)/$long_y; + break; + } + if ( $monitor->HasFocusSpeed() ) { + $speed = intval(round($monitor->MinFocusSpeed()+(($monitor->MaxFocusSpeed()-$monitor->MinFocusSpeed())*$factor))); + $ctrlCommand .= ' --speed='.$speed; + } + switch( $mode ) { + case 'Abs' : + case 'Rel' : + $step = intval(round($monitor->MinFocusStep()+(($monitor->MaxFocusStep()-$monitor->MinFocusStep())*$factor))); + $ctrlCommand .= ' --step='.$step; + break; + case 'Con' : + if ( $monitor->AutoStopTimeout() ) { + $slowSpeed = intval(round($monitor->MinFocusSpeed()+(($monitor->MaxFocusSpeed()-$monitor->MinFocusSpeed())*$slow))); + if ( $speed < $slowSpeed ) { + $ctrlCommand .= ' --autostop'; + } + } + break; + } + break; + case 'zoom' : + switch( $dirn ) { + case 'Tele' : + $factor = ($long_y-($y+1))/$long_y; + break; + case 'Wide' : + $factor = ($y+1)/$long_y; + break; + } + if ( $monitor->HasZoomSpeed() ) { + $speed = intval(round($monitor->MinZoomSpeed()+(($monitor->MaxZoomSpeed()-$monitor->MinZoomSpeed())*$factor))); + $ctrlCommand .= ' --speed='.$speed; + } + switch( $mode ) { + case 'Abs' : + case 'Rel' : + $step = intval(round($monitor->MinZoomStep()+(($monitor->MaxZoomStep()-$monitor->MinZoomStep())*$factor))); + $ctrlCommand .= ' --step='.$step; + break; + case 'Con' : + if ( $monitor->AutoStopTimeout() ) { + $slowSpeed = intval(round($monitor->MinZoomSpeed()+(($monitor->MaxZoomSpeed()-$monitor->MinZoomSpeed())*$slow))); + if ( $speed < $slowSpeed ) { + $ctrlCommand .= ' --autostop'; + } + } + break; + } + break; + case 'iris' : + switch( $dirn ) { + case 'Open' : + $factor = ($long_y-($y+1))/$long_y; + break; + case 'Close' : + $factor = ($y+1)/$long_y; + break; + } + if ( $monitor->HasIrisSpeed() ) { + $speed = intval(round($monitor->MinIrisSpeed()+(($monitor->MaxIrisSpeed()-$monitor->MinIrisSpeed())*$factor))); + $ctrlCommand .= ' --speed='.$speed; + } + switch( $mode ) { + case 'Abs' : + case 'Rel' : + $step = intval(round($monitor->MinIrisStep()+(($monitor->MaxIrisStep()-$monitor->MinIrisStep())*$factor))); + $ctrlCommand .= ' --step='.$step; + break; + } + break; + case 'white' : + switch( $dirn ) { + case 'In' : + $factor = ($long_y-($y+1))/$long_y; + break; + case 'Out' : + $factor = ($y+1)/$long_y; + break; + } + if ( $monitor->HasWhiteSpeed() ) { + $speed = intval(round($monitor->MinWhiteSpeed()+(($monitor->MaxWhiteSpeed()-$monitor->MinWhiteSpeed())*$factor))); + $ctrlCommand .= ' --speed='.$speed; + } + switch( $mode ) { + case 'Abs' : + case 'Rel' : + $step = intval(round($monitor->MinWhiteStep()+(($monitor->MaxWhiteStep()-$monitor->MinWhiteStep())*$factor))); + $ctrlCommand .= ' --step='.$step; + break; + } + break; + case 'gain' : + switch( $dirn ) { + case 'Up' : + $factor = ($long_y-($y+1))/$long_y; + break; + case 'Down' : + $factor = ($y+1)/$long_y; + break; + } + if ( $monitor->HasGainSpeed() ) { + $speed = intval(round($monitor->MinGainSpeed()+(($monitor->MaxGainSpeed()-$monitor->MinGainSpeed())*$factor))); + $ctrlCommand .= ' --speed='.$speed; + } + switch( $mode ) { + case 'Abs' : + case 'Rel' : + $step = intval(round($monitor->MinGainStep()+(($monitor->MaxGainStep()-$monitor->MinGainStep())*$factor))); + $ctrlCommand .= ' --step='.$step; + break; + } + break; + case 'move' : + $xFactor = 0; + $yFactor = 0; + + if ( preg_match( '/^Up/', $dirn ) ) { + $yFactor = ($short_y-($y+1))/$short_y; + } elseif ( preg_match( '/^Down/', $dirn ) ) { + $yFactor = ($y+1)/$short_y; + } + if ( preg_match( '/Left$/', $dirn ) ) { + $xFactor = ($short_x-($x+1))/$short_x; + } elseif ( preg_match( '/Right$/', $dirn ) ) { + $xFactor = ($x+1)/$short_x; + } + + if ( $monitor->Orientation() != '0' ) { + $conversions = array( + '90' => array( + 'Up' => 'Left', + 'Down' => 'Right', + 'Left' => 'Down', + 'Right' => 'Up', + 'UpLeft' => 'DownLeft', + 'UpRight' => 'UpLeft', + 'DownLeft' => 'DownRight', + 'DownRight' => 'UpRight', + ), + '180' => array( + 'Up' => 'Down', + 'Down' => 'Up', + 'Left' => 'Right', + 'Right' => 'Left', + 'UpLeft' => 'DownRight', + 'UpRight' => 'DownLeft', + 'DownLeft' => 'UpRight', + 'DownRight' => 'UpLeft', + ), + '270' => array( + 'Up' => 'Right', + 'Down' => 'Left', + 'Left' => 'Up', + 'Right' => 'Down', + 'UpLeft' => 'UpRight', + 'UpRight' => 'DownRight', + 'DownLeft' => 'UpLeft', + 'DownRight' => 'DownLeft', + ), + 'hori' => array( + 'Up' => 'Up', + 'Down' => 'Down', + 'Left' => 'Right', + 'Right' => 'Left', + 'UpLeft' => 'UpRight', + 'UpRight' => 'UpLeft', + 'DownLeft' => 'DownRight', + 'DownRight' => 'DownLeft', + ), + 'vert' => array( + 'Up' => 'Down', + 'Down' => 'Up', + 'Left' => 'Left', + 'Right' => 'Right', + 'UpLeft' => 'DownLeft', + 'UpRight' => 'DownRight', + 'DownLeft' => 'UpLeft', + 'DownRight' => 'UpRight', + ), + ); + $new_dirn = $conversions[$monitor->Orientation()][$dirn]; + $_REQUEST['control'] = preg_replace( "/_$dirn\$/", "_$new_dirn", $_REQUEST['control'] ); + $dirn = $new_dirn; + } + + if ( $monitor->HasPanSpeed() && $xFactor ) { + if ( $monitor->HasTurboPan() ) { + if ( $xFactor >= $turbo ) { + $panSpeed = $monitor->TurboPanSpeed(); + } else { + $xFactor = $xFactor/$turbo; + $panSpeed = intval(round($monitor->MinPanSpeed()+(($monitor->MaxPanSpeed()-$monitor->MinPanSpeed())*$xFactor))); + } + } else { + $panSpeed = intval(round($monitor->MinPanSpeed()+(($monitor->MaxPanSpeed()-$monitor->MinPanSpeed())*$xFactor))); + } + $ctrlCommand .= ' --panspeed='.$panSpeed; + } + if ( $monitor->HasTiltSpeed() && $yFactor ) { + if ( $monitor->HasTurboTilt() ) { + if ( $yFactor >= $turbo ) { + $tiltSpeed = $monitor->TurboTiltSpeed(); + } else { + $yFactor = $yFactor/$turbo; + $tiltSpeed = intval(round($monitor->MinTiltSpeed()+(($monitor->MaxTiltSpeed()-$monitor->MinTiltSpeed())*$yFactor))); + } + } else { + $tiltSpeed = intval(round($monitor->MinTiltSpeed()+(($monitor->MaxTiltSpeed()-$monitor->MinTiltSpeed())*$yFactor))); + } + $ctrlCommand .= ' --tiltspeed='.$tiltSpeed; + } + switch( $mode ) { + case 'Rel' : + case 'Abs' : + if ( preg_match( '/(Left|Right)$/', $dirn ) ) { + $panStep = intval(round($monitor->MinPanStep()+(($monitor->MaxPanStep()-$monitor->MinPanStep())*$xFactor))); + $ctrlCommand .= ' --panstep='.$panStep; + } + if ( preg_match( '/^(Up|Down)/', $dirn ) ) { + $tiltStep = intval(round($monitor->MinTiltStep()+(($monitor->MaxTiltStep()-$monitor->MinTiltStep())*$yFactor))); + $ctrlCommand .= ' --tiltstep='.$tiltStep; + } + break; + case 'Con' : + if ( $monitor->AutoStopTimeout() ) { + $slowPanSpeed = intval(round($monitor->MinPanSpeed()+(($monitor->MaxPanSpeed()-$monitor->MinPanSpeed())*$slow))); + $slowTiltSpeed = intval(round($monitor->MinTiltSpeed()+(($monitor->MaxTiltSpeed()-$monitor->MinTiltSpeed())*$slow))); + if ( (!isset($panSpeed) || ($panSpeed < $slowPanSpeed)) && (!isset($tiltSpeed) || ($tiltSpeed < $slowTiltSpeed)) ) { + $ctrlCommand .= ' --autostop'; + } + } + break; + } + } + } } - else - { - if ( preg_match( '/^presetGoto(\d+)$/', $_REQUEST['control'], $matches ) ) - { - $_REQUEST['control'] = 'presetGoto'; - $ctrlCommand .= " --preset=".$matches[1]; - } - elseif ( $_REQUEST['control'] == "presetGoto" && !empty($_REQUEST['preset']) ) - { - $ctrlCommand .= " --preset=".$_REQUEST['preset']; - } elseif ( $_REQUEST['control'] == "presetSet" ) { - if ( canEdit( 'Control' ) ) { - $preset = validInt($_REQUEST['preset']); - $newLabel = validJsStr($_REQUEST['newLabel']); - $row = dbFetchOne( 'SELECT * FROM ControlPresets WHERE MonitorId = ? AND Preset = ?', NULL, array( $monitor->Id(), $preset ) ); - if ( $newLabel != $row['Label'] ) { - if ( $newLabel ) { - dbQuery( 'REPLACE INTO ControlPresets ( MonitorId, Preset, Label ) VALUES ( ?, ?, ? )', array( $monitor->Id(), $preset, $newLabel ) ); - } else { - dbQuery( 'DELETE FROM ControlPresets WHERE MonitorId = ? AND Preset = ?', array( $monitor->Id(), $preset ) ); - } - } - $ctrlCommand .= " --preset=".$preset; - } - $ctrlCommand .= " --preset=".$preset; - } - elseif ( $_REQUEST['control'] == "moveMap" ) - { - $ctrlCommand .= " --xcoord=$x --ycoord=$y"; + } else { + if ( preg_match( '/^presetGoto(\d+)$/', $_REQUEST['control'], $matches ) ) { + $_REQUEST['control'] = 'presetGoto'; + $ctrlCommand .= ' --preset='.$matches[1]; + } elseif ( $_REQUEST['control'] == 'presetGoto' && !empty($_REQUEST['preset']) ) { + $ctrlCommand .= ' --preset='.$_REQUEST['preset']; + } elseif ( $_REQUEST['control'] == 'presetSet' ) { + if ( canEdit( 'Control' ) ) { + $preset = validInt($_REQUEST['preset']); + $newLabel = validJsStr($_REQUEST['newLabel']); + $row = dbFetchOne( 'SELECT * FROM ControlPresets WHERE MonitorId = ? AND Preset = ?', NULL, array( $monitor->Id(), $preset ) ); + if ( $newLabel != $row['Label'] ) { + if ( $newLabel ) { + dbQuery( 'REPLACE INTO ControlPresets ( MonitorId, Preset, Label ) VALUES ( ?, ?, ? )', array( $monitor->Id(), $preset, $newLabel ) ); + } else { + dbQuery( 'DELETE FROM ControlPresets WHERE MonitorId = ? AND Preset = ?', array( $monitor->Id(), $preset ) ); + } } + $ctrlCommand .= ' --preset='.$preset; + } + $ctrlCommand .= ' --preset='.$preset; + } elseif ( $_REQUEST['control'] == 'moveMap' ) { + $ctrlCommand .= " --xcoord=$x --ycoord=$y"; } - $ctrlCommand .= " --command=".$_REQUEST['control']; - return( $ctrlCommand ); + } + $ctrlCommand .= ' --command='.$_REQUEST['control']; + return( $ctrlCommand ); } function sendControlCommand($mid,$command) { - // Either connects to running zmcontrol.pl or runs zmcontrol.pl to send the command. - $socket = socket_create( AF_UNIX, SOCK_STREAM, 0 ); - if ( $socket < 0 ) { - Fatal( "socket_create() failed: ".socket_strerror($socket) ); - } - $sockFile = ZM_PATH_SOCKS.'/zmcontrol-'.$mid.'.sock'; - if ( @socket_connect( $socket, $sockFile ) ) { - $options = array(); - foreach ( explode( " ", $command ) as $option ) { - if ( preg_match( '/--([^=]+)(?:=(.+))?/', $option, $matches ) ) { - $options[$matches[1]] = $matches[2]?$matches[2]:1; - } - } - $optionString = jsonEncode( $options ); - if ( !socket_write( $socket, $optionString ) ) { - Fatal( "Can't write to control socket: ".socket_strerror(socket_last_error($socket)) ); - } - socket_close( $socket ); - } else if ( $command != 'quit' ) { - $command .= ' --id='.$mid; + // Either connects to running zmcontrol.pl or runs zmcontrol.pl to send the command. + $socket = socket_create( AF_UNIX, SOCK_STREAM, 0 ); + if ( $socket < 0 ) { + Fatal( 'socket_create() failed: '.socket_strerror($socket) ); + } + $sockFile = ZM_PATH_SOCKS.'/zmcontrol-'.$mid.'.sock'; + if ( @socket_connect( $socket, $sockFile ) ) { + $options = array(); + foreach ( explode( ' ', $command ) as $option ) { + if ( preg_match( '/--([^=]+)(?:=(.+))?/', $option, $matches ) ) { + $options[$matches[1]] = $matches[2]?$matches[2]:1; + } + } + $optionString = jsonEncode( $options ); + if ( !socket_write( $socket, $optionString ) ) { + Fatal( "Can't write to control socket: ".socket_strerror(socket_last_error($socket)) ); + } + socket_close( $socket ); + } else if ( $command != 'quit' ) { + $command .= ' --id='.$mid; - // Can't connect so use script - $ctrlOutput = exec( escapeshellcmd( $command ) ); - } + // Can't connect so use script + $ctrlOutput = exec( escapeshellcmd( $command ) ); + } } // end function sendControlCommand( $mid, $command ) diff --git a/web/includes/functions.php b/web/includes/functions.php index 97c0f1919..ed9c91834 100644 --- a/web/includes/functions.php +++ b/web/includes/functions.php @@ -636,10 +636,10 @@ function getFormChanges( $values, $newValues, $types=false, $columns=false ) { { if ( is_array( $newValues[$key] ) ) { if ( join(',',$newValues[$key]) != $values[$key] ) { - $changes[$key] = "$key = ".dbEscape(join(',',$newValues[$key])); + $changes[$key] = "`$key` = ".dbEscape(join(',',$newValues[$key])); } } elseif ( $values[$key] ) { - $changes[$key] = "$key = ''"; + $changes[$key] = "`$key` = ''"; } break; } @@ -696,9 +696,9 @@ function getFormChanges( $values, $newValues, $types=false, $columns=false ) { { if ( !isset($values[$key]) || ($values[$key] != $value) ) { if ( ! isset($value) || $value == '' ) { - $changes[$key] = "$key = NULL"; + $changes[$key] = "`$key` = NULL"; } else { - $changes[$key] = $key . ' = '.dbEscape(trim($value)); + $changes[$key] = "`$key` = ".dbEscape(trim($value)); } } break; @@ -1198,8 +1198,9 @@ function parseFilter( &$filter, $saveToSession=false, $querySep='&' ) { // Need to specify a storage area, so need to look through other terms looking for a storage area, else we default to ZM_EVENTS_PATH if ( ! $StorageArea ) { for ( $j = 0; $j < count($terms); $j++ ) { - if ( isset($terms[$j]['attr']) and $terms[$j]['attr'] == 'StorageId' ) { - $StorageArea = new Storage( $terms[$j]['val'] ); + if ( isset($terms[$j]['attr']) and $terms[$j]['attr'] == 'StorageId' and isset($terms[$j]['val']) ) { + $StorageArea = new Storage($terms[$j]['val']); + break; } } // end foreach remaining term if ( ! $StorageArea ) $StorageArea = new Storage(); @@ -1211,8 +1212,8 @@ function parseFilter( &$filter, $saveToSession=false, $querySep='&' ) { // Need to specify a storage area, so need to look through other terms looking for a storage area, else we default to ZM_EVENTS_PATH if ( ! $StorageArea ) { for ( $j = $i; $j < count($terms); $j++ ) { - if ( isset($terms[$i]['attr']) and $terms[$i]['attr'] == 'StorageId' ) { - $StorageArea = new Storage( $terms[$i]['val'] ); + if ( isset($terms[$i]['attr']) and $terms[$i]['attr'] == 'StorageId' and isset($terms[$j]['val']) ) { + $StorageArea = new Storage($terms[$i]['val']); } } // end foreach remaining term } // end no StorageArea found yet @@ -1298,8 +1299,10 @@ function parseFilter( &$filter, $saveToSession=false, $querySep='&' ) { $filter['query'] .= $querySep.urlencode("filter[Query][terms][$i][op]").'='.urlencode($terms[$i]['op']); $filter['fields'] .= "\n"; - $filter['query'] .= $querySep.urlencode("filter[Query][terms][$i][val]").'='.urlencode($terms[$i]['val']); - $filter['fields'] .= "\n"; + if ( isset($terms[$i]['val']) ) { + $filter['query'] .= $querySep.urlencode("filter[Query][terms][$i][val]").'='.urlencode($terms[$i]['val']); + $filter['fields'] .= "\n"; + } } // end foreach term if ( isset($terms[$i]['cbr']) ) { $filter['query'] .= $querySep.urlencode("filter[Query][terms][$i][cbr]").'='.urlencode($terms[$i]['cbr']); @@ -2145,7 +2148,8 @@ function cache_bust( $file ) { # To defeat caching. Should probably use md5 hash $parts = pathinfo($file); global $css; - $cacheFile = 'cache/'.$parts['filename'].'-'.$css.'-'.filemtime($file).'.'.$parts['extension']; + $dirname = preg_replace( '/\//', '_', $parts['dirname'] ); + $cacheFile = 'cache/'.$dirname.'_'.$parts['filename'].'-'.$css.'-'.filemtime($file).'.'.$parts['extension']; if ( file_exists( ZM_PATH_WEB.'/'.$cacheFile ) or symlink( ZM_PATH_WEB.'/'.$file, ZM_PATH_WEB.'/'.$cacheFile ) ) { return $cacheFile; } else { diff --git a/web/skins/classic/css/flat/export.css b/web/skins/classic/css/base/export.css similarity index 100% rename from web/skins/classic/css/flat/export.css rename to web/skins/classic/css/base/export.css diff --git a/web/skins/classic/css/flat/jquery-ui-theme.css b/web/skins/classic/css/base/jquery-ui-theme.css similarity index 100% rename from web/skins/classic/css/flat/jquery-ui-theme.css rename to web/skins/classic/css/base/jquery-ui-theme.css diff --git a/web/skins/classic/css/flat/skin.css b/web/skins/classic/css/base/skin.css similarity index 100% rename from web/skins/classic/css/flat/skin.css rename to web/skins/classic/css/base/skin.css diff --git a/web/skins/classic/css/flat/views/console.css b/web/skins/classic/css/base/views/console.css similarity index 100% rename from web/skins/classic/css/flat/views/console.css rename to web/skins/classic/css/base/views/console.css diff --git a/web/skins/classic/css/flat/views/control.css b/web/skins/classic/css/base/views/control.css similarity index 99% rename from web/skins/classic/css/flat/views/control.css rename to web/skins/classic/css/base/views/control.css index a2dbb9429..b3d620f5c 100644 --- a/web/skins/classic/css/flat/views/control.css +++ b/web/skins/classic/css/base/views/control.css @@ -151,5 +151,4 @@ width: 24px; color: #ffffff; text-align: center; - background-color: #016A9D; } diff --git a/web/skins/classic/css/flat/views/controlcaps.css b/web/skins/classic/css/base/views/controlcaps.css similarity index 100% rename from web/skins/classic/css/flat/views/controlcaps.css rename to web/skins/classic/css/base/views/controlcaps.css diff --git a/web/skins/classic/css/flat/views/devices.css b/web/skins/classic/css/base/views/devices.css similarity index 100% rename from web/skins/classic/css/flat/views/devices.css rename to web/skins/classic/css/base/views/devices.css diff --git a/web/skins/classic/css/flat/views/download.css b/web/skins/classic/css/base/views/download.css similarity index 100% rename from web/skins/classic/css/flat/views/download.css rename to web/skins/classic/css/base/views/download.css diff --git a/web/skins/classic/css/flat/views/event.css b/web/skins/classic/css/base/views/event.css similarity index 100% rename from web/skins/classic/css/flat/views/event.css rename to web/skins/classic/css/base/views/event.css diff --git a/web/skins/classic/css/flat/views/events.css b/web/skins/classic/css/base/views/events.css similarity index 100% rename from web/skins/classic/css/flat/views/events.css rename to web/skins/classic/css/base/views/events.css diff --git a/web/skins/classic/css/flat/views/export.css b/web/skins/classic/css/base/views/export.css similarity index 100% rename from web/skins/classic/css/flat/views/export.css rename to web/skins/classic/css/base/views/export.css diff --git a/web/skins/classic/css/flat/views/filter.css b/web/skins/classic/css/base/views/filter.css similarity index 100% rename from web/skins/classic/css/flat/views/filter.css rename to web/skins/classic/css/base/views/filter.css diff --git a/web/skins/classic/css/flat/views/frame.css b/web/skins/classic/css/base/views/frame.css similarity index 100% rename from web/skins/classic/css/flat/views/frame.css rename to web/skins/classic/css/base/views/frame.css diff --git a/web/skins/classic/css/flat/views/frames.css b/web/skins/classic/css/base/views/frames.css similarity index 100% rename from web/skins/classic/css/flat/views/frames.css rename to web/skins/classic/css/base/views/frames.css diff --git a/web/skins/classic/css/flat/views/groups.css b/web/skins/classic/css/base/views/groups.css similarity index 100% rename from web/skins/classic/css/flat/views/groups.css rename to web/skins/classic/css/base/views/groups.css diff --git a/web/skins/classic/css/flat/views/log.css b/web/skins/classic/css/base/views/log.css similarity index 100% rename from web/skins/classic/css/flat/views/log.css rename to web/skins/classic/css/base/views/log.css diff --git a/web/skins/classic/css/flat/views/login.css b/web/skins/classic/css/base/views/login.css similarity index 100% rename from web/skins/classic/css/flat/views/login.css rename to web/skins/classic/css/base/views/login.css diff --git a/web/skins/classic/css/flat/views/monitor.css b/web/skins/classic/css/base/views/monitor.css similarity index 100% rename from web/skins/classic/css/flat/views/monitor.css rename to web/skins/classic/css/base/views/monitor.css diff --git a/web/skins/classic/css/flat/views/montage.css b/web/skins/classic/css/base/views/montage.css similarity index 100% rename from web/skins/classic/css/flat/views/montage.css rename to web/skins/classic/css/base/views/montage.css diff --git a/web/skins/classic/css/flat/views/montage_2wide.css b/web/skins/classic/css/base/views/montage_2wide.css similarity index 100% rename from web/skins/classic/css/flat/views/montage_2wide.css rename to web/skins/classic/css/base/views/montage_2wide.css diff --git a/web/skins/classic/css/flat/views/montage_3wide.css b/web/skins/classic/css/base/views/montage_3wide.css similarity index 100% rename from web/skins/classic/css/flat/views/montage_3wide.css rename to web/skins/classic/css/base/views/montage_3wide.css diff --git a/web/skins/classic/css/flat/views/montage_3wide50enlarge.css b/web/skins/classic/css/base/views/montage_3wide50enlarge.css similarity index 100% rename from web/skins/classic/css/flat/views/montage_3wide50enlarge.css rename to web/skins/classic/css/base/views/montage_3wide50enlarge.css diff --git a/web/skins/classic/css/flat/views/montage_4wide.css b/web/skins/classic/css/base/views/montage_4wide.css similarity index 100% rename from web/skins/classic/css/flat/views/montage_4wide.css rename to web/skins/classic/css/base/views/montage_4wide.css diff --git a/web/skins/classic/css/flat/views/montage_freeform.css b/web/skins/classic/css/base/views/montage_freeform.css similarity index 100% rename from web/skins/classic/css/flat/views/montage_freeform.css rename to web/skins/classic/css/base/views/montage_freeform.css diff --git a/web/skins/classic/css/flat/views/montagereview.css b/web/skins/classic/css/base/views/montagereview.css similarity index 100% rename from web/skins/classic/css/flat/views/montagereview.css rename to web/skins/classic/css/base/views/montagereview.css diff --git a/web/skins/classic/css/flat/views/options.css b/web/skins/classic/css/base/views/options.css similarity index 100% rename from web/skins/classic/css/flat/views/options.css rename to web/skins/classic/css/base/views/options.css diff --git a/web/skins/classic/css/flat/views/plugin.css b/web/skins/classic/css/base/views/plugin.css similarity index 100% rename from web/skins/classic/css/flat/views/plugin.css rename to web/skins/classic/css/base/views/plugin.css diff --git a/web/skins/classic/css/flat/views/stats.css b/web/skins/classic/css/base/views/stats.css similarity index 100% rename from web/skins/classic/css/flat/views/stats.css rename to web/skins/classic/css/base/views/stats.css diff --git a/web/skins/classic/css/flat/views/storage.css b/web/skins/classic/css/base/views/storage.css similarity index 100% rename from web/skins/classic/css/flat/views/storage.css rename to web/skins/classic/css/base/views/storage.css diff --git a/web/skins/classic/css/flat/views/timeline.css b/web/skins/classic/css/base/views/timeline.css similarity index 100% rename from web/skins/classic/css/flat/views/timeline.css rename to web/skins/classic/css/base/views/timeline.css diff --git a/web/skins/classic/css/flat/views/timeline.css.php b/web/skins/classic/css/base/views/timeline.css.php similarity index 100% rename from web/skins/classic/css/flat/views/timeline.css.php rename to web/skins/classic/css/base/views/timeline.css.php diff --git a/web/skins/classic/css/flat/views/video.css b/web/skins/classic/css/base/views/video.css similarity index 100% rename from web/skins/classic/css/flat/views/video.css rename to web/skins/classic/css/base/views/video.css diff --git a/web/skins/classic/css/flat/views/watch.css b/web/skins/classic/css/base/views/watch.css similarity index 100% rename from web/skins/classic/css/flat/views/watch.css rename to web/skins/classic/css/base/views/watch.css diff --git a/web/skins/classic/css/flat/views/zone.css b/web/skins/classic/css/base/views/zone.css similarity index 100% rename from web/skins/classic/css/flat/views/zone.css rename to web/skins/classic/css/base/views/zone.css diff --git a/web/skins/classic/css/flat/views/zones.css b/web/skins/classic/css/base/views/zones.css similarity index 100% rename from web/skins/classic/css/flat/views/zones.css rename to web/skins/classic/css/base/views/zones.css diff --git a/web/skins/classic/css/classic/views/options.css b/web/skins/classic/css/classic/views/options.css index f7123086c..9d5b5ea94 100644 --- a/web/skins/classic/css/classic/views/options.css +++ b/web/skins/classic/css/classic/views/options.css @@ -1,3 +1,7 @@ +#options { + padding-top: 10px; + +} input.small { width: 6em; } diff --git a/web/skins/classic/includes/functions.php b/web/skins/classic/includes/functions.php index e6a0e1fe4..993441cdf 100644 --- a/web/skins/classic/includes/functions.php +++ b/web/skins/classic/includes/functions.php @@ -19,14 +19,14 @@ // -// Don't load in additional JS to these views -$bad_views = array('monitor', 'log'); - function xhtmlHeaders( $file, $title ) { global $css; global $skin; - $skinCssFile = getSkinFile( 'css/'.$css.'/skin.css' ); - $skinCssFilejquery = getSkinFile( 'css/'.$css.'/jquery-ui-theme.css' ); + + # This idea is that we always include the classic css files, + # and then any different skin only needs to contain things that are different. + $baseCssPhpFile = getSkinFile( 'css/base/skin.css.php' ); + $skinCssPhpFile = getSkinFile( 'css/'.$css.'/skin.css.php' ); $skinJsFile = getSkinFile( 'js/skin.js' ); @@ -34,15 +34,22 @@ function xhtmlHeaders( $file, $title ) { $cssJsFile = getSkinFile( 'js/'.$css.'.js' ); $basename = basename( $file, '.php' ); - $viewCssFile = getSkinFile( '/css/'.$css.'/views/'.$basename.'.css' ); - if ($basename == 'watch') { - $viewCssFileExtra = getSkinFile( '/css/'.$css.'/views/control.css' ); - } + $viewCssPhpFile = getSkinFile( '/css/'.$css.'/views/'.$basename.'.css.php' ); $viewJsFile = getSkinFile( 'views/js/'.$basename.'.js' ); $viewJsPhpFile = getSkinFile( 'views/js/'.$basename.'.js.php' ); extract( $GLOBALS, EXTR_OVERWRITE ); + function output_link_if_exists( $files ) { + global $skin; + $html = array(); + foreach ( $files as $file ) { + if ( getSkinFile( $file ) ) { + $html[] = ''; + } + } + return implode("\n", $html); + } ?> @@ -66,19 +73,25 @@ if ( file_exists( "skins/$skin/css/$css/graphics/favicon.ico" ) ) { - - - - - - - + @@ -92,6 +105,7 @@ if ( file_exists( "skins/$skin/css/$css/graphics/favicon.ico" ) ) { + @@ -101,9 +115,6 @@ if ( file_exists( "skins/$skin/css/$css/graphics/favicon.ico" ) ) { - - - + @@ -205,7 +216,7 @@ function getNavBarHTML($reload = null) { ?>
'lower(Name)')); $ServersById = array(); foreach ( $servers as $S ) { $ServersById[$S->Id()] = $S; } session_start(); -foreach ( array('ServerId','StorageId','Status','MonitorId') as $var ) { +foreach ( array('Group', 'ServerId','StorageId','Status','MonitorId') as $var ) { if ( isset( $_REQUEST[$var] ) ) { if ( $_REQUEST[$var] != '' ) { $_SESSION[$var] = $_REQUEST[$var]; @@ -49,7 +49,8 @@ foreach ( $storage_areas as $S ) { diff --git a/web/skins/classic/views/group.php b/web/skins/classic/views/group.php index 11ea093ed..df9ea36d4 100644 --- a/web/skins/classic/views/group.php +++ b/web/skins/classic/views/group.php @@ -92,7 +92,8 @@ if ( $newGroup->Id() ) $sql = 'SELECT Id,Name from Groups'.(count($kids)?' WHERE Id NOT IN ('.implode(',',array_map(function(){return '?';}, $kids )).')' : '').' ORDER BY Name'; $options = array(''=>'None'); foreach ( dbFetchAll( $sql, null, $kids ) as $option ) { - $options[$option['Id']] = $option['Name']; + + $options[$option['Id']] = str_repeat(' ', $Groups[$option['Id']]->depth() ) . $option['Name']; } echo htmlSelect( 'newGroup[ParentId]', $options, $newGroup->ParentId(), array('onchange'=>'configureButtons(this);' )); ?> diff --git a/web/skins/classic/views/groups.php b/web/skins/classic/views/groups.php index 7301020b9..f3ea754e2 100644 --- a/web/skins/classic/views/groups.php +++ b/web/skins/classic/views/groups.php @@ -18,7 +18,7 @@ // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. // -if ( !canView( 'Groups' ) ) { +if ( !canView('Groups') ) { $view = 'error'; return; } @@ -64,8 +64,7 @@ function group_line( $Group ) { global $children; global $max_depth; $html = '