From fda115bebea58bcd34742ed8e9c2105b84c8e8a5 Mon Sep 17 00:00:00 2001 From: Isaac Connor Date: Mon, 30 Jan 2017 16:37:53 -0500 Subject: [PATCH 1/6] tell zmc and zma to stop before updating db --- web/includes/actions.php | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/web/includes/actions.php b/web/includes/actions.php index 6804dbf76..1f0e0ec47 100644 --- a/web/includes/actions.php +++ b/web/includes/actions.php @@ -440,6 +440,10 @@ if ( !empty($action) ) { if ( count( $changes ) ) { if ( $mid ) { + + # If we change anything that changes the shared mem size, zma can complain. So let's stop first. + zmaControl( $monitor, 'stop' ); + zmcControl( $monitor, 'stop' ); dbQuery( 'UPDATE Monitors SET '.implode( ", ", $changes ).' WHERE Id =?', array($mid) ); if ( isset($changes['Name']) ) { $saferOldName = basename( $monitor['Name'] ); @@ -522,17 +526,15 @@ if ( !empty($action) ) { //fixDevices(); //if ( $cookies ) //session_write_close(); - if ( daemonCheck() ) { - zmaControl( $monitor, 'stop' ); - zmcControl( $monitor, 'stop' ); - zmcControl( $new_monitor, 'start' ); - zmaControl( $new_monitor, 'start' ); - } + zmcControl( $new_monitor, 'start' ); + zmaControl( $new_monitor, 'start' ); + if ( $monitor['Controllable'] ) { require_once( 'control_functions.php' ); sendControlCommand( $mid, 'quit' ); } + // really should thump zmwatch and maybe zmtrigger too. //daemonControl( 'restart', 'zmwatch.pl' ); $refreshParent = true; } // end if restart @@ -567,12 +569,12 @@ if ( !empty($action) ) { deletePath( ZM_DIR_EVENTS.'/'.basename($monitor['Name']) ); deletePath( ZM_DIR_EVENTS.'/'.$monitor['Id'] ); // I'm trusting the Id. - } - } - } - } - } - } + } // end if ZM_OPT_FAST_DELETE + } // end if found the monitor in the db + } // end if canedit this monitor + } // end foreach monitor in MarkMid + } // markMids is set and we aren't limited to specific monitors + } // end if action == Delete } // Device view actions From 9fd9c5de20abf6c23cf281d0b32f69fb619e69c5 Mon Sep 17 00:00:00 2001 From: Isaac Connor Date: Mon, 30 Jan 2017 17:24:41 -0500 Subject: [PATCH 2/6] test for empty and non-existent path --- web/includes/Storage.php | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/web/includes/Storage.php b/web/includes/Storage.php index 81b9ad48c..940653404 100644 --- a/web/includes/Storage.php +++ b/web/includes/Storage.php @@ -65,6 +65,14 @@ class Storage { } public function disk_usage_percent() { $path = $this->Path(); + if ( ! $path ) { + Warning("Storage::disk_usage_percent: path is empty"); + return 0; + } else if ( ! file_exists( $path ) ) { + Warning("Storage::disk_usage_percent: path $path does not exist"); + return 0; + } + $total = disk_total_space( $path ); if ( ! $total ) { Error("disk_total_space returned false for " . $path ); From 85727dbe2be39eefea09e740432c0c217cd9e80e Mon Sep 17 00:00:00 2001 From: Isaac Connor Date: Mon, 30 Jan 2017 17:25:07 -0500 Subject: [PATCH 3/6] bump version and set Path to allow NULLS --- db/zm_create.sql.in | 3 +-- db/zm_update-1.30.13.sql | 7 +++++++ version | 2 +- 3 files changed, 9 insertions(+), 3 deletions(-) create mode 100644 db/zm_update-1.30.13.sql diff --git a/db/zm_create.sql.in b/db/zm_create.sql.in index 90fc319f3..039ca7524 100644 --- a/db/zm_create.sql.in +++ b/db/zm_create.sql.in @@ -342,7 +342,7 @@ CREATE TABLE `Monitors` ( `Host` varchar(64), `Port` varchar(8) NOT NULL default '', `SubPath` varchar(64) NOT NULL default '', - `Path` varchar(255) NOT NULL default '', + `Path` varchar(255), `Options` varchar(255), `User` varchar(64), `Pass` varchar(64), @@ -398,7 +398,6 @@ CREATE TABLE `Monitors` ( `WebColour` varchar(32) NOT NULL default 'red', `Exif` tinyint(1) unsigned NOT NULL default '0', `Sequence` smallint(5) unsigned default NULL, - `Orientation` enum('0','90','180','270','hori','vert') NOT NULL default '0', PRIMARY KEY (`Id`) ) ENGINE=@ZM_MYSQL_ENGINE@; diff --git a/db/zm_update-1.30.13.sql b/db/zm_update-1.30.13.sql new file mode 100644 index 000000000..a01357a41 --- /dev/null +++ b/db/zm_update-1.30.13.sql @@ -0,0 +1,7 @@ +-- +-- This updates a 1.30.10 database to 1.30.11 +-- +-- Add StateId Column to Events. +-- + +ALTER TABLE Monitors MODIFY Path VARCHAR(255); diff --git a/version b/version index 09f8e11bf..56abadc20 100644 --- a/version +++ b/version @@ -1 +1 @@ -1.30.12 +1.30.13 From 19aed3f860e6ce6343c5963d4ef74e7608b2c3bc Mon Sep 17 00:00:00 2001 From: Isaac Connor Date: Mon, 30 Jan 2017 17:29:15 -0500 Subject: [PATCH 4/6] dont check ZM_DIR_EVENTS if it already exists in storageareas --- web/skins/classic/includes/functions.php | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/web/skins/classic/includes/functions.php b/web/skins/classic/includes/functions.php index e18a7bd69..aea78aaa2 100644 --- a/web/skins/classic/includes/functions.php +++ b/web/skins/classic/includes/functions.php @@ -266,7 +266,13 @@ if ( canView( 'Stream' ) && $cycleCount > 1 ) {
  • : Path()] = $area; + } + if ( ! $storage_paths[ZM_DIR_EVENTS] ) { array_push( $storage_areas, new Storage() ); + } $func = function($S){ return $S->Name() . ': ' . $S->disk_usage_percent().'%'; }; echo implode( ', ', array_map ( $func, $storage_areas ) ); From 4543b3e1b1560b2fd881e15ef9d726948b6b805f Mon Sep 17 00:00:00 2001 From: Isaac Connor Date: Mon, 30 Jan 2017 19:17:14 -0500 Subject: [PATCH 5/6] include jquery-ui instead of using a cdn version --- web/skins/classic/includes/functions.php | 4 +- web/skins/classic/js/jquery-ui-1.11.3.js | 16608 +++++++++++++++++++++ 2 files changed, 16610 insertions(+), 2 deletions(-) create mode 100644 web/skins/classic/js/jquery-ui-1.11.3.js diff --git a/web/skins/classic/includes/functions.php b/web/skins/classic/includes/functions.php index aea78aaa2..77f970175 100644 --- a/web/skins/classic/includes/functions.php +++ b/web/skins/classic/includes/functions.php @@ -80,9 +80,9 @@ function xhtmlHeaders( $file, $title ) - + -