From fad4339713fe5ae8709f5a78d500429a42828f2a Mon Sep 17 00:00:00 2001 From: Andrew Bauer Date: Mon, 26 Oct 2020 12:12:50 -0500 Subject: [PATCH 01/12] no need for full page reload with server pagination --- web/skins/classic/views/js/events.js | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/web/skins/classic/views/js/events.js b/web/skins/classic/views/js/events.js index ed591e510..f0bd0b3ac 100644 --- a/web/skins/classic/views/js/events.js +++ b/web/skins/classic/views/js/events.js @@ -135,7 +135,7 @@ function manageDelConfirmModalBtns() { $j.getJSON(thisUrl + '?request=events&task=delete&eids[]='+selections.join('&eids[]=')) .done( function(data) { $j('#eventTable').bootstrapTable('refresh'); - window.location.reload(true); + $j('#deleteConfirm').modal('hide'); }) .fail(logAjaxFail); }); @@ -238,7 +238,6 @@ function initPage() { $j.getJSON(thisUrl + '?request=events&task=archive&eids[]='+selections.join('&eids[]=')) .done( function(data) { $j('#eventTable').bootstrapTable('refresh'); - window.location.reload(true); }) .fail(logAjaxFail); }); @@ -257,11 +256,8 @@ function initPage() { $j.getJSON(thisUrl + '?request=events&task=unarchive&eids[]='+selections.join('&eids[]=')) .done( function(data) { $j('#eventTable').bootstrapTable('refresh'); - window.location.reload(true); }) .fail(logAjaxFail); - - //window.location.reload(true); }); // Manage the EDIT button From 7b106e2522eaa0289391d17e5de45de85fa6ce78 Mon Sep 17 00:00:00 2001 From: Andrew Bauer Date: Mon, 26 Oct 2020 12:20:26 -0500 Subject: [PATCH 02/12] don't use wildcards in advanced search --- web/ajax/events.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/web/ajax/events.php b/web/ajax/events.php index 32e8f7ce9..850628109 100644 --- a/web/ajax/events.php +++ b/web/ajax/events.php @@ -155,11 +155,11 @@ function queryRequest($filter, $search, $advsearch, $sort, $offset, $order, $lim foreach ( $advsearch as $col=>$text ) { if ( in_array($col, $columns) ) { - $text = '%' .$text. '%'; + //$text = '%' .$text. '%'; array_push($likes, 'E.'.$col.' LIKE ?'); array_push($query['values'], $text); } else if ( in_array($col, $col_alt) ) { - $text = '%' .$text. '%'; + //$text = '%' .$text. '%'; array_push($likes, 'M.'.$col.' LIKE ?'); array_push($query['values'], $text); } else { From f3f0a6baff2de703928a23ef2362d5fd4b053cfa Mon Sep 17 00:00:00 2001 From: Isaac Connor Date: Mon, 26 Oct 2020 18:48:43 -0400 Subject: [PATCH 03/12] remove debug --- src/zm_ffmpeg_camera.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/src/zm_ffmpeg_camera.cpp b/src/zm_ffmpeg_camera.cpp index e04f5e8ca..7d990bcd2 100644 --- a/src/zm_ffmpeg_camera.cpp +++ b/src/zm_ffmpeg_camera.cpp @@ -664,7 +664,6 @@ int FfmpegCamera::OpenFfmpeg() { } // int FfmpegCamera::OpenFfmpeg() int FfmpegCamera::Close() { - Debug(2, "CloseFfmpeg called."); mCanCapture = false; From a5bb2365b54d09fcc983e72a77a28582a961ab8f Mon Sep 17 00:00:00 2001 From: Isaac Connor Date: Mon, 26 Oct 2020 18:49:03 -0400 Subject: [PATCH 04/12] update auth_relay when we update auth_hash --- web/skins/classic/js/skin.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/web/skins/classic/js/skin.js b/web/skins/classic/js/skin.js index f6cbb328a..85449927c 100644 --- a/web/skins/classic/js/skin.js +++ b/web/skins/classic/js/skin.js @@ -372,10 +372,14 @@ if ( currentView != 'none' && currentView != 'login' ) { } if ( data.auth ) { if ( data.auth != auth_hash ) { + console.log("Update auth_hash to "+data.auth); // Update authentication token. auth_hash = data.auth; } } + if ( data.auth_relay ) { + auth_relay = data.auth_relay; + } // iterate through all the keys then update each element id with the same name for (var key of Object.keys(data)) { if ( key == "auth" ) continue; From 1690bcbd381a4f461bbbf5ac72c091212037c116 Mon Sep 17 00:00:00 2001 From: Isaac Connor Date: Mon, 26 Oct 2020 18:49:14 -0400 Subject: [PATCH 05/12] update auth_relay when we update auth_hash --- web/ajax/status.php | 1 + 1 file changed, 1 insertion(+) diff --git a/web/ajax/status.php b/web/ajax/status.php index 0bafe16e4..190d239ad 100644 --- a/web/ajax/status.php +++ b/web/ajax/status.php @@ -6,6 +6,7 @@ if ( $_REQUEST['entity'] == 'navBar' ) { $auth_hash = generateAuthHash(ZM_AUTH_HASH_IPS); if ( isset($_REQUEST['auth']) and ($_REQUEST['auth'] != $auth_hash) ) { $data['auth'] = $auth_hash; + $data['auth_relay'] = get_auth_relay(); } } // Each widget on the navbar has its own function From c67b3c5a1f1189e41f2cf617481a7874785378b8 Mon Sep 17 00:00:00 2001 From: Isaac Connor Date: Mon, 26 Oct 2020 18:49:41 -0400 Subject: [PATCH 06/12] fix button disabled status. We now have checkboxes that aren't actions so we need to be more explicit --- web/skins/classic/views/js/filter.js | 53 +++++++++++++--------------- 1 file changed, 25 insertions(+), 28 deletions(-) diff --git a/web/skins/classic/views/js/filter.js b/web/skins/classic/views/js/filter.js index fd7ee94ca..707fb06e1 100644 --- a/web/skins/classic/views/js/filter.js +++ b/web/skins/classic/views/js/filter.js @@ -74,35 +74,32 @@ function validateForm(form) { function updateButtons(element) { var form = element.form; - if ( element.type == 'checkbox' && element.checked ) { - form.elements['executeButton'].disabled = false; - } else { - var canExecute = false; - if ( form.elements['filter[AutoArchive]'] && form.elements['filter[AutoArchive]'].checked ) { - canExecute = true; - } else if ( form.elements['filter[AutoUnarchive]'] && form.elements['filter[AutoUnarchive]'].checked ) { - canExecute = true; - } else if ( form.elements['filter[AutoCopy]'] && form.elements['filter[AutoCopy]'].checked ) { - canExecute = true; - } else if ( form.elements['filter[AutoMove]'] && form.elements['filter[AutoMove]'].checked ) { - canExecute = true; - } else if ( form.elements['filter[AutoVideo]'] && form.elements['filter[AutoVideo]'].checked ) { - canExecute = true; - } else if ( form.elements['filter[AutoUpload]'] && form.elements['filter[AutoUpload]'].checked ) { - canExecute = true; - } else if ( form.elements['filter[AutoEmail]'] && form.elements['filter[AutoEmail]'].checked ) { - canExecute = true; - } else if ( form.elements['filter[AutoMessage]'] && form.elements['filter[AutoMessage]'].checked ) { - canExecute = true; - } else if ( form.elements['filter[AutoExecute]'].checked && form.elements['filter[AutoExecuteCmd]'].value != '' ) { - canExecute = true; - } else if ( form.elements['filter[AutoDelete]'].checked ) { - canExecute = true; - } else if ( form.elements['filter[UpdateDiskSpace]'].checked ) { - canExecute = true; - } - form.elements['executeButton'].disabled = !canExecute; + + var canExecute = false; + if ( form.elements['filter[AutoArchive]'] && form.elements['filter[AutoArchive]'].checked ) { + canExecute = true; + } else if ( form.elements['filter[AutoUnarchive]'] && form.elements['filter[AutoUnarchive]'].checked ) { + canExecute = true; + } else if ( form.elements['filter[AutoCopy]'] && form.elements['filter[AutoCopy]'].checked ) { + canExecute = true; + } else if ( form.elements['filter[AutoMove]'] && form.elements['filter[AutoMove]'].checked ) { + canExecute = true; + } else if ( form.elements['filter[AutoVideo]'] && form.elements['filter[AutoVideo]'].checked ) { + canExecute = true; + } else if ( form.elements['filter[AutoUpload]'] && form.elements['filter[AutoUpload]'].checked ) { + canExecute = true; + } else if ( form.elements['filter[AutoEmail]'] && form.elements['filter[AutoEmail]'].checked ) { + canExecute = true; + } else if ( form.elements['filter[AutoMessage]'] && form.elements['filter[AutoMessage]'].checked ) { + canExecute = true; + } else if ( form.elements['filter[AutoExecute]'].checked && form.elements['filter[AutoExecuteCmd]'].value != '' ) { + canExecute = true; + } else if ( form.elements['filter[AutoDelete]'].checked ) { + canExecute = true; + } else if ( form.elements['filter[UpdateDiskSpace]'].checked ) { + canExecute = true; } + form.elements['executeButton'].disabled = !canExecute; if ( form.elements['filter[Name]'].value ) { form.elements['Save'].disabled = false; form.elements['SaveAs'].disabled = false; From 3825af8243e997eaec725aa2a967ba422a3bf652 Mon Sep 17 00:00:00 2001 From: Isaac Connor Date: Wed, 28 Oct 2020 09:19:54 -0400 Subject: [PATCH 07/12] Add FOREIGN KEYS for EventId in Frames, Stats. MonitorId, ZoneId in Stats. MonitorId in Zones. --- db/zm_create.sql.in | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/db/zm_create.sql.in b/db/zm_create.sql.in index 71d07ad07..940ba2a82 100644 --- a/db/zm_create.sql.in +++ b/db/zm_create.sql.in @@ -315,6 +315,7 @@ DROP TABLE IF EXISTS `Frames`; CREATE TABLE `Frames` ( `Id` BIGINT UNSIGNED NOT NULL AUTO_INCREMENT, `EventId` BIGINT UNSIGNED NOT NULL default '0', + FOREIGN KEY (`EventId`) REFERENCES `Events` (`Id`) ON DELETE CASCADE, `FrameId` int(10) unsigned NOT NULL default '0', `Type` enum('Normal','Bulk','Alarm') NOT NULL default 'Normal', `TimeStamp` timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP, @@ -608,8 +609,11 @@ DROP TABLE IF EXISTS `Stats`; CREATE TABLE `Stats` ( `Id` int(10) unsigned NOT NULL AUTO_INCREMENT, `MonitorId` int(10) unsigned NOT NULL default '0', + FOREIGN KEY (`MonitorId`) REFERENCES `Monitors` (`Id`) ON DELETE CASCADE, `ZoneId` int(10) unsigned NOT NULL default '0', + FOREIGN KEY (`ZoneId`) REFERENCES `Zones` (`Id`) ON DELETE CASCADE, `EventId` BIGINT UNSIGNED NOT NULL, + FOREIGN KEY (`EventId`) REFERENCES `Events` (`Id`) ON DELETE CASCADE, `FrameId` int(10) unsigned NOT NULL default '0', `PixelDiff` tinyint(3) unsigned NOT NULL default '0', `AlarmPixels` int(10) unsigned NOT NULL default '0', @@ -704,6 +708,7 @@ DROP TABLE IF EXISTS `Zones`; CREATE TABLE `Zones` ( `Id` int(10) unsigned NOT NULL auto_increment, `MonitorId` int(10) unsigned NOT NULL default '0', + FOREIGN KEY (`MonitorId`) REFERENCES `Monitors` (`Id`) ON DELETE CASCADE, `Name` varchar(64) NOT NULL default '', `Type` enum('Active','Inclusive','Exclusive','Preclusive','Inactive','Privacy') NOT NULL default 'Active', `Units` enum('Pixels','Percent') NOT NULL default 'Pixels', From 59884375fa5df340daa1cb9dbf245111aadda7bc Mon Sep 17 00:00:00 2001 From: Isaac Connor Date: Wed, 28 Oct 2020 09:23:46 -0400 Subject: [PATCH 08/12] Add references permission so that our zmupdate can add foreign keys --- distros/beowulf/zoneminder.postinst | 4 ++-- distros/ubuntu1604/zoneminder.postinst | 2 +- distros/ubuntu2004/zoneminder.postinst | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/distros/beowulf/zoneminder.postinst b/distros/beowulf/zoneminder.postinst index 603786ff6..032595355 100644 --- a/distros/beowulf/zoneminder.postinst +++ b/distros/beowulf/zoneminder.postinst @@ -39,9 +39,9 @@ if [ "$1" = "configure" ]; then exit 1; fi # This creates the user. - echo "grant lock tables, alter,drop,select,insert,update,delete,create,index,alter routine,create routine, trigger,execute on ${ZM_DB_NAME}.* to '${ZM_DB_USER}'@localhost identified by \"${ZM_DB_PASS}\";" | mysql --defaults-file=/etc/mysql/debian.cnf mysql + echo "grant lock tables, alter,drop,select,insert,update,delete,create,index,alter routine,create routine, trigger,execute, REFERENCES on ${ZM_DB_NAME}.* to '${ZM_DB_USER}'@localhost identified by \"${ZM_DB_PASS}\";" | mysql --defaults-file=/etc/mysql/debian.cnf mysql else - echo "grant lock tables, alter,drop,select,insert,update,delete,create,index,alter routine,create routine, trigger,execute on ${ZM_DB_NAME}.* to '${ZM_DB_USER}'@localhost;" | mysql --defaults-file=/etc/mysql/debian.cnf mysql + echo "grant lock tables, alter,drop,select,insert,update,delete,create,index,alter routine,create routine, trigger,execute, REFERENCES on ${ZM_DB_NAME}.* to '${ZM_DB_USER}'@localhost;" | mysql --defaults-file=/etc/mysql/debian.cnf mysql fi zmupdate.pl --nointeractive diff --git a/distros/ubuntu1604/zoneminder.postinst b/distros/ubuntu1604/zoneminder.postinst index 7b7af708b..d89ccf531 100644 --- a/distros/ubuntu1604/zoneminder.postinst +++ b/distros/ubuntu1604/zoneminder.postinst @@ -68,7 +68,7 @@ if [ "$1" = "configure" ]; then echo "CREATE USER '${ZM_DB_USER}'@localhost IDENTIFIED BY '${ZM_DB_PASS}';" | mysql --defaults-file=/etc/mysql/debian.cnf mysql fi echo "Updating permissions" - echo "grant lock tables,alter,drop,select,insert,update,delete,create,index,alter routine,create routine, trigger,execute on ${ZM_DB_NAME}.* to '${ZM_DB_USER}'@localhost;" | mysql --defaults-file=/etc/mysql/debian.cnf mysql + echo "GRANT LOCK TABLES,ALTER,DROP,SELECT,INSERT,UPDATE,DELETE,CREATE,INDEX,ALTER ROUTINE,CREATE ROUTINE, TRIGGER,EXECUTE,REFERENCES ON ${ZM_DB_NAME}.* TO '${ZM_DB_USER}'@localhost;" | mysql --defaults-file=/etc/mysql/debian.cnf mysql zmupdate.pl --nointeractive zmupdate.pl --nointeractive -f diff --git a/distros/ubuntu2004/zoneminder.postinst b/distros/ubuntu2004/zoneminder.postinst index a8b8eaf51..a50d7cf2e 100644 --- a/distros/ubuntu2004/zoneminder.postinst +++ b/distros/ubuntu2004/zoneminder.postinst @@ -26,7 +26,7 @@ create_update_user () { echo "CREATE USER '${ZM_DB_USER}'@${ZM_DB_HOST} IDENTIFIED BY '${ZM_DB_PASS}';" | mysql --defaults-file=/etc/mysql/debian.cnf mysql fi echo "Updating permissions" - echo "GRANT LOCK tables,alter,drop,select,insert,update,delete,create,index,alter routine,create routine,trigger,execute ON ${ZM_DB_NAME}.* TO '${ZM_DB_USER}'@${ZM_DB_HOST};" | mysql --defaults-file=/etc/mysql/debian.cnf mysql + echo "GRANT LOCK tables,alter,drop,select,insert,update,delete,create,index,alter routine,create routine,trigger,execute,REFERENCES ON ${ZM_DB_NAME}.* TO '${ZM_DB_USER}'@${ZM_DB_HOST};" | mysql --defaults-file=/etc/mysql/debian.cnf mysql } update_db () { From 43b7021f9cd3a0b719c721cb9f4c95e7827e55b6 Mon Sep 17 00:00:00 2001 From: Isaac Connor Date: Wed, 28 Oct 2020 12:38:44 -0400 Subject: [PATCH 09/12] ALTER Events.Id to BIGINT. This update got lost at somepoint. Add FOREIGN KEYS to Frames, Stats and Zones tables --- db/zm_update-1.35.11.sql | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 db/zm_update-1.35.11.sql diff --git a/db/zm_update-1.35.11.sql b/db/zm_update-1.35.11.sql new file mode 100644 index 000000000..e0257c184 --- /dev/null +++ b/db/zm_update-1.35.11.sql @@ -0,0 +1,22 @@ + +/* Change Id type to BIGINT. */ +ALTER TABLE Events MODIFY Id bigint unsigned NOT NULL auto_increment; + +/* Add FOREIGN KEYS After deleting lost records */ +DELETE FROM Frames WHERE EventId NOT IN (SELECT Id FROM Events); +ALTER TABLE Frames ADD FOREIGN KEY (EventId) REFERENCES Events (Id) ON DELETE CASCADE; + +/* Add FOREIGN KEYS After deleting lost records */ +DELETE FROM Stats WHERE EventId NOT IN (SELECT Id FROM Events); +ALTER TABLE Stats ADD FOREIGN KEY (EventId) REFERENCES Events (Id) ON DELETE CASCADE; + +DELETE FROM Stats WHERE MonitorId NOT IN (SELECT Id FROM Monitors); +ALTER TABLE Stats ADD FOREIGN KEY (`MonitorId`) REFERENCES `Monitors` (`Id`) ON DELETE CASCADE; + +DELETE FROM Stats WHERE ZoneId NOT IN (SELECT Id FROM Zones); +ALTER TABLE Stats ADD FOREIGN KEY (`ZoneId`) REFERENCES `Zones` (`Id`) ON DELETE CASCADE; + +/* Add FOREIGN KEYS After deleting lost records */ +DELETE FROM Zones WHERE MonitorId NOT IN (SELECT Id FROM Monitors); +ALTER TABLE Zones ADD FOREIGN KEY (`MonitorId`) REFERENCES `Monitors` (`Id`) ON DELETE CASCADE; + From 4c92c99ba17e3b4107c8d40230a69214e926dc26 Mon Sep 17 00:00:00 2001 From: Isaac Connor Date: Wed, 28 Oct 2020 12:39:50 -0400 Subject: [PATCH 10/12] bump version for 1.35.11 db updates --- distros/redhat/zoneminder.spec | 2 +- version | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/distros/redhat/zoneminder.spec b/distros/redhat/zoneminder.spec index 5c19dd0c0..3a4d45de8 100644 --- a/distros/redhat/zoneminder.spec +++ b/distros/redhat/zoneminder.spec @@ -28,7 +28,7 @@ %global _hardened_build 1 Name: zoneminder -Version: 1.35.10 +Version: 1.35.11 Release: 1%{?dist} Summary: A camera monitoring and analysis tool Group: System Environment/Daemons diff --git a/version b/version index a0b71b46f..5f1e3b58b 100644 --- a/version +++ b/version @@ -1 +1 @@ -1.35.10 +1.35.11 From b3a28b2ba20b858eea71be965bbdeae8662a3cb8 Mon Sep 17 00:00:00 2001 From: Isaac Connor Date: Wed, 28 Oct 2020 12:49:03 -0400 Subject: [PATCH 11/12] fix confusion in syslog reporting web_php when the error was actually web_js --- web/includes/logger.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/web/includes/logger.php b/web/includes/logger.php index fb7d58f93..ab59b412b 100644 --- a/web/includes/logger.php +++ b/web/includes/logger.php @@ -408,10 +408,10 @@ class Logger { } } - $message = $code.' ['.$string.']'; if ( $level <= $this->syslogLevel ) - syslog( self::$syslogPriorities[$level], $message ); + syslog(self::$syslogPriorities[$level], $message); + $message = $code.' ['.$string.']'; if ( $level <= $this->databaseLevel ) { try { global $dbConn; From 686f793d097973c15f62d89a670c9cf2fb1d648c Mon Sep 17 00:00:00 2001 From: Isaac Connor Date: Wed, 28 Oct 2020 12:49:39 -0400 Subject: [PATCH 12/12] fix truth value for ZM_OPT_USE_GEOLOCATION --- web/skins/classic/views/js/monitor.js.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/web/skins/classic/views/js/monitor.js.php b/web/skins/classic/views/js/monitor.js.php index cc61270d0..bdcc17554 100644 --- a/web/skins/classic/views/js/monitor.js.php +++ b/web/skins/classic/views/js/monitor.js.php @@ -1,4 +1,4 @@ -var ZM_OPT_USE_GEOLOCATION = ''; +var ZM_OPT_USE_GEOLOCATION = '' == '1' ? true : false;