diff --git a/db/zm_create.sql.in b/db/zm_create.sql.in index b2824b075..240e8f345 100644 --- a/db/zm_create.sql.in +++ b/db/zm_create.sql.in @@ -559,7 +559,8 @@ CREATE TABLE `Servers` ( `Protocol` TEXT, `Hostname` TEXT, `Port` INTEGER UNSIGNED, - `PathPrefix` TEXT, + `PathToIndex` TEXT, + `PathToZMS` TEXT, `Name` varchar(64) NOT NULL default '', `State_Id` int(10) unsigned, `Status` enum('Unknown','NotRunning','Running') NOT NULL default 'Unknown', diff --git a/db/zm_update-1.32.3.sql b/db/zm_update-1.32.3.sql index 68d617824..17bb3c3ab 100644 --- a/db/zm_update-1.32.3.sql +++ b/db/zm_update-1.32.3.sql @@ -2,12 +2,6 @@ -- This updates a 1.32.2 database to 1.32.3 -- --- --- Add some additional monitor preset values --- - -INSERT INTO MonitorPresets VALUES (NULL,'D-link DCS-930L, 640x480, mjpeg','Remote','http',0,0,'http','simple','',80,'/mjpeg.cgi',NULL,640,480,3,NULL,0,NULL,NULL,NULL,100,100); - -- -- Add Protocol column to Storage -- @@ -25,16 +19,32 @@ PREPARE stmt FROM @s; EXECUTE stmt; -- --- Add Prefix column to Storage +-- Add PathToIndex column to Storage -- SET @s = (SELECT IF( (SELECT COUNT(*) FROM INFORMATION_SCHEMA.COLUMNS WHERE table_schema = DATABASE() AND table_name = 'Servers' - AND column_name = 'PathPrefix' + AND column_name = 'PathToIndex' ) > 0, -"SELECT 'Column PathPrefix already exists in Servers'", -"ALTER TABLE Servers ADD `PathPrefix` TEXT AFTER `Hostname`" +"SELECT 'Column PathToIndex already exists in Servers'", +"ALTER TABLE Servers ADD `PathToIndex` TEXT AFTER `Hostname`" +)); + +PREPARE stmt FROM @s; +EXECUTE stmt; + +-- +-- Add PathToZMS column to Storage +-- + +SET @s = (SELECT IF( + (SELECT COUNT(*) FROM INFORMATION_SCHEMA.COLUMNS WHERE table_schema = DATABASE() + AND table_name = 'Servers' + AND column_name = 'PathToZMS' + ) > 0, +"SELECT 'Column PathToZMS already exists in Servers'", +"ALTER TABLE Servers ADD `PathToZMS` TEXT AFTER `PathToIndex`" )); PREPARE stmt FROM @s; diff --git a/scripts/ZoneMinder/lib/ZoneMinder/Event.pm b/scripts/ZoneMinder/lib/ZoneMinder/Event.pm index 8c8bf4944..9c6fe3cd5 100644 --- a/scripts/ZoneMinder/lib/ZoneMinder/Event.pm +++ b/scripts/ZoneMinder/lib/ZoneMinder/Event.pm @@ -450,9 +450,23 @@ sub delete_files { } } # end sub delete_files +sub StorageId { + my $event = shift; + if ( @_ ) { + $$event{StorageId} = shift; + delete $$event{Storage}; + delete $$event{Path}; + } + return $$event{StorageId}; +} + sub Storage { if ( @_ > 1 ) { $_[0]{Storage} = $_[1]; + if ( $_[0]{Storage} ) { + $_[0]{StorageId} = $_[0]{Storage}->Id(); + delete $_[0]{Path}; + } } if ( ! $_[0]{Storage} ) { $_[0]{Storage} = new ZoneMinder::Storage($_[0]{StorageId}); diff --git a/scripts/zmaudit.pl.in b/scripts/zmaudit.pl.in index afd4881a0..ce3fb1397 100644 --- a/scripts/zmaudit.pl.in +++ b/scripts/zmaudit.pl.in @@ -176,8 +176,10 @@ MAIN: while( $loop ) { } # end while can't connect to the db my @Storage_Areas; + my @all_Storage_Areas = ZoneMinder::Storage->find(); + if ( defined $storage_id ) { - @Storage_Areas = ZoneMinder::Storage->find( Id=>$storage_id ); + @Storage_Areas = map { $$_{Id} == $storage_id ? $_ : () } @all_Storage_Areas; if ( !@Storage_Areas ) { Error("No Storage Area found with Id $storage_id"); Term(); @@ -403,7 +405,7 @@ MAIN: while( $loop ) { $$Event{RelativePath} = $event_dir; $Event->MonitorId( $monitor_dir ); $Event->StorageId( $Storage->Id() ); - $Event->StartTime( POSIX::strftime('%Y-%m-%d %H:%M:%S', gmtime(time_of_youngest_file($$Event{Path})) ) ); + $Event->StartTime( POSIX::strftime('%Y-%m-%d %H:%M:%S', gmtime(time_of_youngest_file($Event->Path())) ) ); } # end foreach event } @@ -523,7 +525,7 @@ MAIN: while( $loop ) { # If we found the monitor in the file system my $fs_events = $fs_monitors->{$db_monitor}; - while ( my ( $db_event, $age ) = each( %$db_events ) ) { +EVENT: while ( my ( $db_event, $age ) = each( %$db_events ) ) { if ( ! ($fs_events and defined( $fs_events->{$db_event} ) ) ) { Debug("Don't have an fs event for $db_event"); my $Event = ZoneMinder::Event->find_one( Id=>$db_event ); @@ -533,13 +535,15 @@ MAIN: while( $loop ) { } Debug("Event $db_event is not in fs. Should have been at ".$Event->Path()); # Check for existence in other Storage Areas - foreach my $Storage ( ZoneMinder::Storage->find( ( $$Event{StorageId} ? ( 'Id !='=>$$Event{StorageId} ) : () ) ) ) { + foreach my $Storage ( @all_Storage_Areas ) { + next if $$Storage{Id} == $$Event{StorageId}; + my $path = $Storage->Path().'/'.$Event->RelativePath(); if ( -e $path ) { Info("Event $$Event{Id} found at $path instead of $$Event{Path}"); - if ( confirm() ) { + if ( confirm('update', 'updating') ) { $Event->save({StorageId=>$$Storage{Id}}); - last; + next EVENT; } } else { Debug("$$Event{Id} Not found at $path"); @@ -587,6 +591,7 @@ MAIN: while( $loop ) { Warning("Not found at " . $Event->Path() . ' was found at ' . $$fs_events{$db_event}->Path() ); Warning($Event->to_string()); Warning($$fs_events{$db_event}->to_string()); + $$Event{Scheme} = '' if ! defined $$Event{Scheme}; if ( $$fs_events{$db_event}->Scheme() ne $Event->Scheme() ) { Info("Updating scheme on event $$Event{Id} from $$Event{Scheme} to $$fs_events{$db_event}{Scheme}"); $Event->Scheme($$fs_events{$db_event}->Scheme()); @@ -996,7 +1001,7 @@ sub delete_empty_directories { #Debug("delete_empty_directories $_[0] has " . @contents .' entries:' . ( @contents <= 2 ? join(',',@contents) : '' )); my @dirs = map { -d $_[0].'/'.$_ ? $_ : () } @contents; if ( @dirs ) { - Debug("Have " . @dirs . " dirs"); + Debug("Have " . @dirs . " dirs in $_[0]"); foreach ( @dirs ) { delete_empty_directories( $_[0].'/'.$_ ); } diff --git a/web/api/app/Controller/MonitorsController.php b/web/api/app/Controller/MonitorsController.php index 69799a820..8908955b5 100644 --- a/web/api/app/Controller/MonitorsController.php +++ b/web/api/app/Controller/MonitorsController.php @@ -361,6 +361,7 @@ class MonitorsController extends AppController { )); $monitor = $monitor['Monitor']; + $daemons = array(); if ( ! $daemon ) { if ( $monitor['Function'] == 'Monitor' ) { array_push($daemons, 'zmc'); diff --git a/web/includes/Server.php b/web/includes/Server.php index e39c92a3e..55d6ebc6e 100644 --- a/web/includes/Server.php +++ b/web/includes/Server.php @@ -72,6 +72,19 @@ class Server { return $_SERVER['SERVER_PORT']; } + public function PathToZMS( $new = null ) { + if ( $new != null ) + $this{'PathToZMS'} = $new; + if ( $this->Id() and $this->{'PathToZMS'} ) { + return $this->{'PathToZMS'}; + } else { + return ZM_PATH_ZMS; + } + } + public function UrlToZMS( ) { + return $this->Url().$this->PathToZMS(); + } + public function Url( $port = null ) { $url = $this->Protocol().'://'; if ( $this->Id() ) { @@ -84,21 +97,24 @@ class Server { } else { $url .= ':'.$this->Port(); } - $url .= $this->PathPrefix(); return $url; } - public function PathPrefix( $new = null ) { + public function PathToIndex( $new = null ) { if ( $new != null ) - $this->{'PathPrefix'} = $new; + $this->{'PathToIndex'} = $new; - if ( isset($this->{'PathPrefix'}) and $this->{'PathPrefix'} ) { - return $this->{'PathPrefix'}; + if ( isset($this->{'PathToIndex'}) and $this->{'PathToIndex'} ) { + return $this->{'PathToIndex'}; } return ''; //return $_SERVER['PHP_SELF']; } + public function UrlToIndex( ) { + return $this->Url().$this->PathToIndex(); + } + public function __call($fn, array $args){ if ( count($args) ) { $this->{$fn} = $args[0]; diff --git a/web/lang/en_gb.php b/web/lang/en_gb.php index 83f5e1f73..51b61b6ba 100644 --- a/web/lang/en_gb.php +++ b/web/lang/en_gb.php @@ -586,7 +586,8 @@ $SLANG = array( 'Parameter' => 'Parameter', 'Password' => 'Password', 'PasswordsDifferent' => 'The new and confirm passwords are different', - 'PathPrefix' => 'Path Prefix', + 'PathToIndex' => 'Path To Index', + 'PathToZMS' => 'Path To ZMS', 'Paths' => 'Paths', 'Pause' => 'Pause', 'PhoneBW' => 'Phone B/W', diff --git a/web/skins/classic/views/js/montage.js.php b/web/skins/classic/views/js/montage.js.php index 183f17648..fe298ab10 100644 --- a/web/skins/classic/views/js/montage.js.php +++ b/web/skins/classic/views/js/montage.js.php @@ -35,7 +35,7 @@ monitorData[monitorData.length] = { 'connKey': connKey() ?>, 'width': Width() ?>, 'height':Height() ?>, - 'url': 'Url() ?>', + 'url': 'UrlToIndex() ?>', 'onclick': function(){createPopup( '?view=watch&mid=Id() ?>', 'zmWatchId() ?>', 'watch', Width(), $monitor->PopupScale() ); ?>, Height(), $monitor->PopupScale() ); ?> );}, 'type': 'Type() ?>', 'refresh': 'Refresh() ?>' diff --git a/web/skins/classic/views/js/watch.js b/web/skins/classic/views/js/watch.js index 1cef843cd..6a9bf39cd 100644 --- a/web/skins/classic/views/js/watch.js +++ b/web/skins/classic/views/js/watch.js @@ -500,11 +500,11 @@ function getEventCmdResponse( respObj, respText ) { var cells = row.getElements( 'td' ); - var link = new Element( 'a', { 'href': '#', 'events': { 'click': createEventPopup.pass( [ event.Id, '&terms=1&attr1=MonitorId&op1=%3d&val1='+monitorId+'&page=1&popup=1', event.Width, event.Height ] ) } }); + var link = new Element( 'a', { 'href': '#', 'events': { 'click': createEventPopup.pass( [ event.Id, '&filter[Query][terms][0][attr]=MonitorId&filter[Query][terms][0][op]=%3d&filter[Query][terms][0][val]='+monitorId+'&page=1&popup=1', event.Width, event.Height ] ) } }); link.set( 'text', event.Id ); link.inject( row.getElement( 'td.colId' ) ); - link = new Element( 'a', { 'href': '#', 'events': { 'click': createEventPopup.pass( [ event.Id, '&terms=1&attr1=MonitorId&op1=%3d&val1='+monitorId+'&page=1&popup=1', event.Width, event.Height ] ) } }); + link = new Element( 'a', { 'href': '#', 'events': { 'click': createEventPopup.pass( [ event.Id, '&filter[Query][terms][0][attr]=MonitorId&filter[Query][terms][0][op]=%3d&filter[Query][terms][0][val]='+monitorId+'&page=1&popup=1', event.Width, event.Height ] ) } }); link.set( 'text', event.Name ); link.inject( row.getElement( 'td.colName' ) ); diff --git a/web/skins/classic/views/js/watch.js.php b/web/skins/classic/views/js/watch.js.php index d9826c66f..15a43a6ce 100644 --- a/web/skins/classic/views/js/watch.js.php +++ b/web/skins/classic/views/js/watch.js.php @@ -48,7 +48,7 @@ var maxDisplayEvents = ; var monitorId = Id() ?>; var monitorWidth = Width() ?>; var monitorHeight = Height() ?>; -var monitorUrl = 'Url(); ?>/index.php'; +var monitorUrl = 'UrlToIndex(); ?>'; var monitorType = 'Type() ) ?>'; var monitorRefresh = 'Refresh() ) ?>'; diff --git a/web/skins/classic/views/js/zone.js.php b/web/skins/classic/views/js/zone.js.php index 434fec679..069a0de54 100644 --- a/web/skins/classic/views/js/zone.js.php +++ b/web/skins/classic/views/js/zone.js.php @@ -101,7 +101,7 @@ var streamMode = ""; var connKey = ''; var monitorId = Id() ?>; -var monitorUrl = 'Url() ) ?>'; +var monitorUrl = 'UrlToIndex() ) ?>'; var streamSrc = ""; diff --git a/web/skins/classic/views/js/zones.js.php b/web/skins/classic/views/js/zones.js.php index d7144d18a..6bd9c402c 100644 --- a/web/skins/classic/views/js/zones.js.php +++ b/web/skins/classic/views/js/zones.js.php @@ -1,4 +1,4 @@ var connKey = ''; -var monitorUrl = 'Url() ) ?>'; +var monitorUrl = 'UrlToIndex() ) ?>'; var CMD_QUIT = ; diff --git a/web/skins/classic/views/options.php b/web/skins/classic/views/options.php index 7d595ee06..d34901694 100644 --- a/web/skins/classic/views/options.php +++ b/web/skins/classic/views/options.php @@ -209,6 +209,8 @@ foreach ( array_map('basename', glob('skins/'.$current_skin.'/css/*',GLOB_ONLYDI + + @@ -228,7 +230,9 @@ foreach ( array_map('basename', glob('skins/'.$current_skin.'/css/*',GLOB_ONLYDI Id(), 'zmServer', 'server', validHtmlStr($Server->Name()), $canEdit) ?> Id(), 'zmServer', 'server', validHtmlStr($Server->Url()), $canEdit) ?> - + Id(), 'zmServer', 'server', validHtmlStr($Server->PathToIndex()), $canEdit) ?> + Id(), 'zmServer', 'server', validHtmlStr($Server->PathToZMS()), $canEdit) ?> + Id(), 'zmServer', 'server', validHtmlStr($Server->Status()), $canEdit) ?> Id(), 'zmServer', 'server', validHtmlStr($monitor_counts[$Server->Id()]), $canEdit) ?> diff --git a/web/skins/classic/views/server.php b/web/skins/classic/views/server.php index 2a4ebe785..6b8f41893 100644 --- a/web/skins/classic/views/server.php +++ b/web/skins/classic/views/server.php @@ -23,33 +23,23 @@ if ( !canEdit('System') ) { return; } -if ( $_REQUEST['id'] ) { - if ( !($newServer = dbFetchOne('SELECT * FROM Servers WHERE Id = ?', NULL, ARRAY($_REQUEST['id'])) ) ) { - $view = 'error'; - return; - } -} else { - $newServer = array(); - $newServer['Name'] = translate('NewServer'); - $newServer['Protocol'] = (!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off' || $_SERVER['SERVER_PORT'] == 443) ? 'https' : 'http'; - $newServer['Hostname'] = ''; - $newServer['PathPrefix'] = '/zm'; - $newServer['zmstats'] = ''; - $newServer['zmaudit'] = ''; - $newServer['zmtrigger'] = ''; +$Server = new Server($_REQUEST['id']); +if ( $_REQUEST['id'] and ! $Server->Id() ) { + $view = 'error'; + return; } $focusWindow = true; -xhtmlHeaders(__FILE__, translate('Server').' - '.$newServer['Name']); +xhtmlHeaders(__FILE__, translate('Server').' - '.$Server->Name()); ?>
-
+ @@ -57,43 +47,47 @@ xhtmlHeaders(__FILE__, translate('Server').' - '.$newServer['Name']); - + - + - + - + - - + + + + + + - /> Yes - /> No + zmstats() ? ' checked="checked"' : '' ?>/> Yes + zmstats() ? '' : ' checked="checked"' ?>/> No - /> Yes - /> No + zmaudit() ? ' checked="checked"' : '' ?>/> Yes + zmaudit() ? '' : ' checked="checked"' ?>/> No - /> Yes - /> No + zmtrigger() ? ' checked="checked"' : '' ?>/> Yes + zmtrigger() ? '' : ' checked="checked"' ?>/> No