From 5602b92699eff5cd2ffbab36fe24b724d35d70f0 Mon Sep 17 00:00:00 2001 From: Isaac Connor Date: Thu, 17 Dec 2020 09:26:59 -0500 Subject: [PATCH 1/9] Fix issue with timeline where it only shows first frame --- web/skins/classic/views/js/timeline.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/web/skins/classic/views/js/timeline.js b/web/skins/classic/views/js/timeline.js index 8742ac67b..2b75cddba 100644 --- a/web/skins/classic/views/js/timeline.js +++ b/web/skins/classic/views/js/timeline.js @@ -132,7 +132,7 @@ function requestFrameData( eventId, frameId ) { function previewEvent(slot) { eventId = slot.getAttribute('data-event-id'); frameId = slot.getAttribute('data-frame-id'); - if ( events[eventId] ) { + if ( events[eventId] && events[eventId]['frames'] && events[eventId]['frames'][frameId] ) { showEventData(eventId, frameId); } else { requestFrameData(eventId, frameId); From c9ac5dff626e82e2eb7df3d10f618af9c7b9493c Mon Sep 17 00:00:00 2001 From: Isaac Connor Date: Mon, 21 Dec 2020 12:17:02 -0500 Subject: [PATCH 2/9] Use parent printMsg --- scripts/ZoneMinder/lib/ZoneMinder/Control/onvif.pm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/ZoneMinder/lib/ZoneMinder/Control/onvif.pm b/scripts/ZoneMinder/lib/ZoneMinder/Control/onvif.pm index c830d28aa..f69441aff 100644 --- a/scripts/ZoneMinder/lib/ZoneMinder/Control/onvif.pm +++ b/scripts/ZoneMinder/lib/ZoneMinder/Control/onvif.pm @@ -65,7 +65,7 @@ sub sendCmd { my $self = shift; my $cmd = shift; my $result = undef; - printMsg($cmd, 'Tx'); + $this->printMsg($cmd, 'Tx'); my $req = HTTP::Request->new(GET=>'http://'.$self->{Monitor}->{ControlAddress}.'/'.$cmd); my $res = $self->{ua}->request($req); From b019a759a3798a10d9baa31a4518ed2449680c66 Mon Sep 17 00:00:00 2001 From: Isaac Connor Date: Fri, 15 Jan 2021 18:43:49 -0500 Subject: [PATCH 3/9] ffmpeg options doesn't support loglevel setting. SO remove it from help. Fixes #3109 --- web/lang/en_gb.php | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/web/lang/en_gb.php b/web/lang/en_gb.php index c423a3507..1e2545616 100644 --- a/web/lang/en_gb.php +++ b/web/lang/en_gb.php @@ -979,9 +979,8 @@ $OLANG = array( 'Help' => ' Parameters in this field are passed on to FFmpeg. Multiple parameters can be separated by ,~~ Examples (do not enter quotes)~~~~ - "allowed_media_types=video" Set datatype to request fromcam (audio, video, data)~~~~ - "reorder_queue_size=nnn" Set number of packets to buffer for handling of reordered packets~~~~ - "loglevel=debug" Set verbosity of FFmpeg (quiet, panic, fatal, error, warning, info, verbose, debug) + "allowed_media_types=video" Set datatype to request from cam (audio, video, data)~~~~ + "reorder_queue_size=nnn" Set number of packets to buffer for handling of reordered packets ' ), 'OPTIONS_ENCODER_PARAMETERS' => array( From 7183a47a3ad72c93b5f80f09ba040f94e16db378 Mon Sep 17 00:00:00 2001 From: Isaac Connor Date: Fri, 15 Jan 2021 18:45:13 -0500 Subject: [PATCH 4/9] split Netcat security header into multiple lines for legibility --- scripts/ZoneMinder/lib/ZoneMinder/Control/Netcat.pm | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/scripts/ZoneMinder/lib/ZoneMinder/Control/Netcat.pm b/scripts/ZoneMinder/lib/ZoneMinder/Control/Netcat.pm index 4f6bca07c..b2356bb61 100644 --- a/scripts/ZoneMinder/lib/ZoneMinder/Control/Netcat.pm +++ b/scripts/ZoneMinder/lib/ZoneMinder/Control/Netcat.pm @@ -122,7 +122,17 @@ sub authentificationHeader { my $nonceBase64 = encode_base64($nonce, ''); my $currentDate = DateTime->now()->iso8601().'Z'; - return '' . $username . '' . digestBase64($nonce, $currentDate, $password) . '' . $nonceBase64 . '' . $currentDate . ''; + return ' + + + + ' . $username . ' + ' . digestBase64($nonce, $currentDate, $password) . ' + ' . $nonceBase64 . ' + ' . $currentDate . ' + + +'; } sub sendCmd { From 6586aa633810cbe7ff8698fe4cf0ff270d3a202e Mon Sep 17 00:00:00 2001 From: Isaac Connor Date: Sat, 16 Jan 2021 13:15:34 -0500 Subject: [PATCH 5/9] Introduce a helper function bindButton to do the button event binding with nice error logging. --- web/skins/classic/js/skin.js | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/web/skins/classic/js/skin.js b/web/skins/classic/js/skin.js index ea8ea2885..2d027dbfe 100644 --- a/web/skins/classic/js/skin.js +++ b/web/skins/classic/js/skin.js @@ -813,6 +813,16 @@ function manageModalBtns(id) { }); } +function bindButton(selector, action, data, func) { + var elements = $j(selector); + if ( !elements.length ) { + console.log("Nothing found for " + selector); + return; + } + elements.on(action, data, func); +} + + function human_filesize(size, precision = 2) { var units = Array('B', 'kB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB'); var step = 1024; From d98dde4aee2cf075600dccb941aee22588aa9af6 Mon Sep 17 00:00:00 2001 From: Isaac Connor Date: Sat, 16 Jan 2021 13:16:23 -0500 Subject: [PATCH 6/9] Use auth hash in event loading. Use monitorURL in ajax calls that need to talk to zms. Use bindButton to handle the non-existence of settings button. --- web/skins/classic/views/js/watch.js | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/web/skins/classic/views/js/watch.js b/web/skins/classic/views/js/watch.js index 84d6957e8..42da61fac 100644 --- a/web/skins/classic/views/js/watch.js +++ b/web/skins/classic/views/js/watch.js @@ -40,6 +40,7 @@ function ajaxRequest(params) { params.data.order = 'desc'; params.data.limit = maxDisplayEvents; params.data.sort = 'Id'; + if ( auth_hash ) params.data.auth = auth_hash; $j.getJSON(thisUrl + '?view=request&request=events&task=query'+filterQuery, params.data) .done(function(data) { @@ -282,8 +283,8 @@ function getStreamCmdResponse(respObj, respText) { checkStreamForErrors('getStreamCmdResponse', respObj);//log them // Try to reload the image stream. // If it's an auth error, we should reload the whole page. - window.location.reload(); - if ( 0 ) { + //window.location.reload(); + if ( 1 ) { var streamImg = $j('#liveStream'+monitorId); if ( streamImg ) { var oldSrc = streamImg.attr('src'); @@ -351,7 +352,7 @@ function streamCmdPlay( action ) { } function streamCmdReq(data) { - $j.getJSON(thisUrl + '?view=request&request=stream&connkey='+connKey, data) + $j.getJSON(monitorUrl + '?view=request&request=stream&connkey='+connKey, data) .done(getStreamCmdResponse) .fail(getStreamCmdError); @@ -519,7 +520,7 @@ function getStatusCmdResponse(respObj, respText) { } function statusCmdQuery() { - $j.getJSON(thisUrl + '?view=request&request=status&entity=monitor&element[]=Status&element[]=FrameRate&id='+monitorId) + $j.getJSON(monitorUrl + '?view=request&request=status&entity=monitor&element[]=Status&element[]=FrameRate&id='+monitorId) .done(getStatusCmdResponse) .fail(logAjaxFail); @@ -527,7 +528,7 @@ function statusCmdQuery() { } function alarmCmdReq(data) { - $j.getJSON(thisUrl + '?view=request&request=alarm&id='+monitorId, data) + $j.getJSON(monitorUrl + '?view=request&request=alarm&id='+monitorId, data) .done(getAlarmCmdResponse) .fail(function(jqxhr, textStatus, error) { if (textstatus === "timeout") { @@ -590,7 +591,7 @@ function cmdForce() { } function controlReq(data) { - $j.getJSON(thisUrl + '?view=request&request=control&id='+monitorId, data) + $j.getJSON(monitorUrl + '?view=request&request=control&id='+monitorId, data) .done(getControlResponse) .fail(logAjaxFail); } @@ -750,7 +751,7 @@ function updatePresetLabels() { } function getCtrlPresetModal() { - $j.getJSON(thisUrl + '?request=modal&modal=controlpreset&mid=' + monitorId) + $j.getJSON(monitorUrl + '?request=modal&modal=controlpreset&mid=' + monitorId) .done(function(data) { insertModalHtml('ctrlPresetModal', data.html); updatePresetLabels(); @@ -766,7 +767,7 @@ function getCtrlPresetModal() { } function getSettingsModal() { - $j.getJSON(thisUrl + '?request=modal&modal=settings&mid=' + monitorId) + $j.getJSON(monitorUrl + '?request=modal&modal=settings&mid=' + monitorId) .done(function(data) { insertModalHtml('settingsModal', data.html); // Manage the Save button @@ -780,7 +781,7 @@ function getSettingsModal() { function processClicks(event, field, value, row, $element) { if ( field == 'Delete' ) { - $j.getJSON(thisUrl + '?request=modal&modal=delconfirm') + $j.getJSON(monitorUrl + '?request=modal&modal=delconfirm') .done(function(data) { insertModalHtml('deleteConfirm', data.html); manageDelConfirmModalBtns(); @@ -878,7 +879,7 @@ function initPage() { } // Manage the BACK button - document.getElementById("backBtn").addEventListener("click", function onBackClick(evt) { + bindButton('#backBtn', 'click', null, function onBackClick(evt) { evt.preventDefault(); window.history.back(); }); @@ -887,13 +888,13 @@ function initPage() { backBtn.prop('disabled', !document.referrer.length); // Manage the REFRESH Button - document.getElementById("refreshBtn").addEventListener("click", function onRefreshClick(evt) { + bindButton('#refreshBtn', 'click', null, function onRefreshClick(evt) { evt.preventDefault(); window.location.reload(true); }); // Manage the SETTINGS button - document.getElementById("settingsBtn").addEventListener("click", function onSettingsClick(evt) { + bindButton('settingsBtn', 'click', null, function onSettingsClick(evt) { evt.preventDefault(); $j('#settingsModal').modal('show'); }); From 3dc35c49a2b2e9fe91f9a6994af0f5041b2a92b9 Mon Sep 17 00:00:00 2001 From: Isaac Connor Date: Sat, 16 Jan 2021 13:16:36 -0500 Subject: [PATCH 7/9] quotes --- web/skins/classic/js/skin.js.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/web/skins/classic/js/skin.js.php b/web/skins/classic/js/skin.js.php index a15d32526..4ba7efb73 100644 --- a/web/skins/classic/js/skin.js.php +++ b/web/skins/classic/js/skin.js.php @@ -43,7 +43,7 @@ var serverId = ''; var canView = {}; var canEdit = {}; canView[""] = ; @@ -60,7 +60,7 @@ if ( ! empty($refreshParent) ) { echo 'true'; } else if ( $refreshParent ) { # This is to tell the parent to refresh to a specific URL - echo "'$refreshParent'"; + echo '\''.$refreshParent.'\''; } else { echo 'false'; } From 50af7f25b8f1d32a953dbce552e174b1d5229348 Mon Sep 17 00:00:00 2001 From: Isaac Connor Date: Sat, 16 Jan 2021 13:17:31 -0500 Subject: [PATCH 8/9] Use less memory in event querying. More work to do here --- web/ajax/events.php | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/web/ajax/events.php b/web/ajax/events.php index 51949f84e..8a8e3a4f1 100644 --- a/web/ajax/events.php +++ b/web/ajax/events.php @@ -165,8 +165,6 @@ function queryRequest($filter, $search, $advsearch, $sort, $offset, $order, $lim $col_str = 'E.*, M.Name AS Monitor'; $sql = 'SELECT ' .$col_str. ' FROM `Events` AS E INNER JOIN Monitors AS M ON E.MonitorId = M.Id'.$where.' ORDER BY '.$sort.' '.$order; - //ZM\Debug('Calling the following sql query: ' .$sql); - $storage_areas = ZM\Storage::find(); $StorageById = array(); foreach ( $storage_areas as $S ) { @@ -176,14 +174,18 @@ function queryRequest($filter, $search, $advsearch, $sort, $offset, $order, $lim $unfiltered_rows = array(); $event_ids = array(); - foreach ( dbFetchAll($sql, NULL, $values) as $row ) { - $event = new ZM\Event($row); - if ( !$filter->test_post_sql_conditions($event) ) { + ZM\Debug('Calling the following sql query: ' .$sql); + $query = dbQuery($sql, $values); + if ( $query ) { + while ( $row = dbFetchNext($query) ) { + $event = new ZM\Event($row); $event->remove_from_cache(); - continue; - } - $event_ids[] = $event->Id(); - $unfiltered_rows[] = $row; + if ( !$filter->test_post_sql_conditions($event) ) { + continue; + } + $event_ids[] = $event->Id(); + $unfiltered_rows[] = $row; + } # end foreach row } ZM\Debug('Have ' . count($unfiltered_rows) . ' events matching base filter.'); @@ -218,6 +220,7 @@ function queryRequest($filter, $search, $advsearch, $sort, $offset, $order, $lim } # end if search $sql = 'SELECT ' .$col_str. ' FROM `Events` AS E INNER JOIN Monitors AS M ON E.MonitorId = M.Id WHERE '.$search_filter->sql().' ORDER BY ' .$sort. ' ' .$order; + ZM\Debug('Calling the following sql query: ' .$sql); $filtered_rows = dbFetchAll($sql); ZM\Debug('Have ' . count($filtered_rows) . ' events matching search filter.'); } else { From 5186ae2433d975136110c4dbc40871689740830c Mon Sep 17 00:00:00 2001 From: Isaac Connor Date: Sat, 16 Jan 2021 13:17:43 -0500 Subject: [PATCH 9/9] use bindButton --- web/skins/classic/views/js/event.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/web/skins/classic/views/js/event.js b/web/skins/classic/views/js/event.js index 565beba0f..a25201d44 100644 --- a/web/skins/classic/views/js/event.js +++ b/web/skins/classic/views/js/event.js @@ -1034,14 +1034,14 @@ function initPage() { }); // Manage the FRAMES Button - document.getElementById("framesBtn").addEventListener("click", function onFramesClick(evt) { + bindButton('#framesBtn', 'click', null, function onFramesClick(evt) { evt.preventDefault(); window.location.assign('?view=frames&eid='+eventData.Id); }); // Manage the DELETE button - document.getElementById("deleteBtn").addEventListener("click", function onDeleteClick(evt) { - if ( ! canEdit.Events ) { + bindButton('#deleteBtn', 'click', null, function onDeleteClick(evt) { + if ( !canEdit.Events ) { enoperm(); return; } @@ -1060,7 +1060,7 @@ function initPage() { } $j('#deleteConfirm').modal('show'); }); -} +} // end initPage // Kick everything off $j(document).ready(initPage);