From c6e3107a505b8c4c50e509f3a223669746d5c936 Mon Sep 17 00:00:00 2001 From: Andrew Bauer Date: Mon, 24 Aug 2020 09:31:21 -0500 Subject: [PATCH 01/36] make donate view a modal --- web/skins/classic/views/console.php | 6 ++- web/skins/classic/views/donate.php | 58 +++++++++++++++------------ web/skins/classic/views/js/console.js | 2 +- 3 files changed, 38 insertions(+), 28 deletions(-) diff --git a/web/skins/classic/views/console.php b/web/skins/classic/views/console.php index a6e75ef54..c7ca643ad 100644 --- a/web/skins/classic/views/console.php +++ b/web/skins/classic/views/console.php @@ -425,4 +425,8 @@ for( $monitor_i = 0; $monitor_i < count($displayMonitors); $monitor_i += 1 ) { - + diff --git a/web/skins/classic/views/donate.php b/web/skins/classic/views/donate.php index 6cf873bd4..502377133 100644 --- a/web/skins/classic/views/donate.php +++ b/web/skins/classic/views/donate.php @@ -33,32 +33,38 @@ $options = array( 'already' => translate('DonateAlready'), ); -$focusWindow = true; - -xhtmlHeaders(__FILE__, translate('Donate')); ?> - -
- -
-
- - -

- -

-

- -

-
- - -
-
+ + + diff --git a/web/skins/classic/views/js/console.js b/web/skins/classic/views/js/console.js index cce137c25..ab8fc8daa 100644 --- a/web/skins/classic/views/js/console.js +++ b/web/skins/classic/views/js/console.js @@ -140,7 +140,7 @@ function initPage() { createPopup('?view=version', 'zmVersion', 'version'); } if ( showDonatePopup ) { - createPopup('?view=donate', 'zmDonate', 'donate'); + $j('#donate').modal('show'); } // Makes table sortable From e5e2c3b347dc1e277e8ef51827edcb4854609e3f Mon Sep 17 00:00:00 2001 From: Andrew Bauer Date: Mon, 24 Aug 2020 10:57:54 -0500 Subject: [PATCH 02/36] fix stats off by 1 frame, don't alert on score 0 --- src/zm_zone.cpp | 2 +- web/skins/classic/views/js/frames.js | 4 ---- 2 files changed, 1 insertion(+), 5 deletions(-) diff --git a/src/zm_zone.cpp b/src/zm_zone.cpp index ee7a5c829..ef943dd02 100644 --- a/src/zm_zone.cpp +++ b/src/zm_zone.cpp @@ -136,7 +136,7 @@ void Zone::RecordStats(const Event *event) { db_mutex.lock(); snprintf(sql, sizeof(sql), "INSERT INTO Stats SET MonitorId=%d, ZoneId=%d, EventId=%" PRIu64 ", FrameId=%d, PixelDiff=%d, AlarmPixels=%d, FilterPixels=%d, BlobPixels=%d, Blobs=%d, MinBlobSize=%d, MaxBlobSize=%d, MinX=%d, MinY=%d, MaxX=%d, MaxY=%d, Score=%d", - monitor->Id(), id, event->Id(), event->Frames()+1, pixel_diff, alarm_pixels, alarm_filter_pixels, alarm_blob_pixels, alarm_blobs, min_blob_size, max_blob_size, alarm_box.LoX(), alarm_box.LoY(), alarm_box.HiX(), alarm_box.HiY(), score + monitor->Id(), id, event->Id(), event->Frames(), pixel_diff, alarm_pixels, alarm_filter_pixels, alarm_blob_pixels, alarm_blobs, min_blob_size, max_blob_size, alarm_box.LoX(), alarm_box.LoY(), alarm_box.HiX(), alarm_box.HiY(), score ); if ( mysql_query(&dbconn, sql) ) { Error("Can't insert event stats: %s", mysql_error(&dbconn)); diff --git a/web/skins/classic/views/js/frames.js b/web/skins/classic/views/js/frames.js index 0cdfb5545..0b5f45846 100644 --- a/web/skins/classic/views/js/frames.js +++ b/web/skins/classic/views/js/frames.js @@ -19,11 +19,7 @@ function initThumbAnimation() { function processClicks(event, field, value, row, $element) { if ( field == 'FramesScore' ) { - if ( value > 0 ) { window.location.assign('?view=stats&eid='+row.EventId+'&fid='+row.FramesId); - } else { - alert("No statistics available"); - } } else { window.location.assign('?view=frame&eid='+row.EventId+'&fid='+row.FramesId); } From 56e2ac5baa9c7d7a0ce72e651ca064198fe46f0d Mon Sep 17 00:00:00 2001 From: Isaac Connor Date: Mon, 24 Aug 2020 12:05:14 -0400 Subject: [PATCH 03/36] add scale to query params because zms doesn't wupport width&height --- web/skins/classic/views/console.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/web/skins/classic/views/console.php b/web/skins/classic/views/console.php index a6e75ef54..b473d09ed 100644 --- a/web/skins/classic/views/console.php +++ b/web/skins/classic/views/console.php @@ -286,9 +286,10 @@ for( $monitor_i = 0; $monitor_i < count($displayMonitors); $monitor_i += 1 ) { $imgHTML=''; if ( ZM_WEB_LIST_THUMBS && $monitor['Status'] == 'Connected' && $running ) { $options = array(); - $ratio_factor = $Monitor->Height()/ $Monitor->Width(); + $ratio_factor = $Monitor->Height() / $Monitor->Width(); $options['width'] = ZM_WEB_LIST_THUMB_WIDTH; $options['height'] = ZM_WEB_LIST_THUMB_HEIGHT ? ZM_WEB_LIST_THUMB_HEIGHT : ZM_WEB_LIST_THUMB_WIDTH*$ratio_factor; + $options['scale'] = intval(ZM_WEB_LIST_THUMB_WIDTH / $Monitor->Width()); $options['mode'] = 'single'; $stillSrc = $Monitor->getStreamSrc($options); From 8c32511c8332ae6e6d8db13662c40b8d5ea20cae Mon Sep 17 00:00:00 2001 From: Andrew Bauer Date: Mon, 24 Aug 2020 12:05:31 -0500 Subject: [PATCH 04/36] whitespace --- web/skins/classic/views/js/frames.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/web/skins/classic/views/js/frames.js b/web/skins/classic/views/js/frames.js index 0b5f45846..7bba691eb 100644 --- a/web/skins/classic/views/js/frames.js +++ b/web/skins/classic/views/js/frames.js @@ -19,7 +19,7 @@ function initThumbAnimation() { function processClicks(event, field, value, row, $element) { if ( field == 'FramesScore' ) { - window.location.assign('?view=stats&eid='+row.EventId+'&fid='+row.FramesId); + window.location.assign('?view=stats&eid='+row.EventId+'&fid='+row.FramesId); } else { window.location.assign('?view=frame&eid='+row.EventId+'&fid='+row.FramesId); } From 41c1774e4af6238e7132df5397fdb707d405832a Mon Sep 17 00:00:00 2001 From: Andrew Bauer Date: Mon, 24 Aug 2020 12:33:22 -0500 Subject: [PATCH 05/36] remove ftp upload folder from specfile --- distros/redhat/zoneminder.spec | 3 --- 1 file changed, 3 deletions(-) diff --git a/distros/redhat/zoneminder.spec b/distros/redhat/zoneminder.spec index 4728734ea..9e876324e 100644 --- a/distros/redhat/zoneminder.spec +++ b/distros/redhat/zoneminder.spec @@ -204,7 +204,6 @@ mv -f CakePHP-Enum-Behavior-%{ceb_version} ./web/api/app/Plugin/CakePHP-Enum-Beh # Change the following default values ./utils/zmeditconfigdata.sh ZM_OPT_CAMBOZOLA yes -./utils/zmeditconfigdata.sh ZM_UPLOAD_FTP_LOC_DIR %{_localstatedir}/spool/zoneminder-upload ./utils/zmeditconfigdata.sh ZM_OPT_CONTROL yes ./utils/zmeditconfigdata.sh ZM_CHECK_FOR_UPDATES no ./utils/zmeditconfigdata.sh ZM_DYN_SHOW_DONATE_REMINDER no @@ -399,7 +398,6 @@ EOF %dir %attr(755,%{zmuid_final},%{zmgid_final}) %{_sharedstatedir}/zoneminder/temp %dir %attr(755,%{zmuid_final},%{zmgid_final}) %{_localstatedir}/cache/zoneminder %dir %attr(755,%{zmuid_final},%{zmgid_final}) %{_localstatedir}/log/zoneminder -%dir %attr(755,%{zmuid_final},%{zmgid_final}) %{_localstatedir}/spool/zoneminder-upload %files nginx %config(noreplace) %attr(640,root,nginx) %{_sysconfdir}/zm/zm.conf @@ -423,7 +421,6 @@ EOF %dir %attr(755,nginx,nginx) %{_sharedstatedir}/zoneminder/temp %dir %attr(755,nginx,nginx) %{_localstatedir}/cache/zoneminder %dir %attr(755,nginx,nginx) %{_localstatedir}/log/zoneminder -%dir %attr(755,nginx,nginx) %{_localstatedir}/spool/zoneminder-upload %changelog * Tue Feb 04 2020 Andrew Bauer - 1.34.2-1 From 3c1651d98fac7e555472260a16e99d762d79ece6 Mon Sep 17 00:00:00 2001 From: Isaac Connor Date: Mon, 24 Aug 2020 14:35:59 -0400 Subject: [PATCH 06/36] in getStreamSrc if scale isn't set figure it out from width and height if passed --- web/includes/Monitor.php | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/web/includes/Monitor.php b/web/includes/Monitor.php index d9c6df4c1..7492f661f 100644 --- a/web/includes/Monitor.php +++ b/web/includes/Monitor.php @@ -133,7 +133,7 @@ class Monitor extends ZM_Object { public function Server() { if ( !property_exists($this, 'Server') ) { - if ( $this->ServerId() ) + if ( $this->ServerId() ) $this->{'Server'} = Server::find_one(array('Id'=>$this->{'ServerId'})); if ( !property_exists($this, 'Server') ) { $this->{'Server'} = new Server(); @@ -205,9 +205,13 @@ class Monitor extends ZM_Object { if ( ZM_RAND_STREAM ) { $args['rand'] = time(); } - foreach ( array('scale') as $int_arg ) { - if ( isset($args[$int_arg]) and (!is_numeric($args[$int_arg]) or !$args[$int_arg] ) ) { - unset($args[$int_arg]); + + # zms doesn't support width & height, so if no scale is set, default it + if ( ! isset($args['scale']) ) { + if ( isset($args['width']) and intval($args['width']) ) { + $args['scale'] = intval((100*intval($args['width']))/$this->ViewWidth()); + } else if ( isset($args['height']) and intval($args['height']) ) { + $args['scale'] = intval((100*intval($args['height']))/$this->ViewHeight()); } } @@ -307,7 +311,7 @@ class Monitor extends ZM_Object { $context = stream_context_create(); try { $result = file_get_contents($url, false, $context); - if ( $result === FALSE ) { /* Handle error */ + if ( $result === FALSE ) { /* Handle error */ Error("Error restarting zmc using $url"); } } catch ( Exception $e ) { @@ -326,7 +330,7 @@ class Monitor extends ZM_Object { if ( (!defined('ZM_SERVER_ID')) or ( property_exists($this, 'ServerId') and (ZM_SERVER_ID==$this->{'ServerId'}) ) ) { if ( $this->{'Function'} == 'None' || $this->{'Function'} == 'Monitor' || $mode == 'stop' ) { - if ( ZM_OPT_CONTROL && $this->Controllable() && $this->TrackMotion() && + if ( ZM_OPT_CONTROL && $this->Controllable() && $this->TrackMotion() && ( $this->{'Function'} == 'Modect' || $this->{'Function'} == 'Mocord' ) ) { daemonControl('stop', 'zmtrack.pl', '-m '.$this->{'Id'}); } @@ -339,7 +343,7 @@ class Monitor extends ZM_Object { daemonControl('stop', 'zma', '-m '.$this->{'Id'}); } daemonControl('start', 'zma', '-m '.$this->{'Id'}); - if ( ZM_OPT_CONTROL && $this->Controllable() && $this->TrackMotion() && + if ( ZM_OPT_CONTROL && $this->Controllable() && $this->TrackMotion() && ( $this->{'Function'} == 'Modect' || $this->{'Function'} == 'Mocord' ) ) { daemonControl('start', 'zmtrack.pl', '-m '.$this->{'Id'}); } @@ -438,8 +442,8 @@ class Monitor extends ZM_Object { $this->{'Storage'} = $new; } if ( ! ( property_exists($this, 'Storage') and $this->{'Storage'} ) ) { - $this->{'Storage'} = isset($this->{'StorageId'}) ? - Storage::find_one(array('Id'=>$this->{'StorageId'})) : + $this->{'Storage'} = isset($this->{'StorageId'}) ? + Storage::find_one(array('Id'=>$this->{'StorageId'})) : new Storage(NULL); if ( ! $this->{'Storage'} ) $this->{'Storage'} = new Storage(NULL); @@ -480,7 +484,7 @@ class Monitor extends ZM_Object { if ( isset($url_parts['port']) and ( $url_parts['port'] == '80' or $url_parts['port'] == '554' ) ) unset($url_parts['port']); $source = unparse_url($url_parts); - } else { # Don't filter anything + } else { # Don't filter anything $source = $this->{'Path'}; } } From 2d05fbda8d0bb73e7e597b3d53b08d26e96c988d Mon Sep 17 00:00:00 2001 From: Isaac Connor Date: Mon, 24 Aug 2020 14:36:36 -0400 Subject: [PATCH 07/36] simplify debug line --- web/includes/database.php | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/web/includes/database.php b/web/includes/database.php index 7404d085e..4298b4ce8 100644 --- a/web/includes/database.php +++ b/web/includes/database.php @@ -153,10 +153,7 @@ function dbQuery($sql, $params=NULL) { } } if ( defined('ZM_DB_DEBUG') ) { - if ( $params ) - ZM\Logger::Debug("SQL: $sql " . implode(',',$params) . ' rows: '.$result->rowCount()); - else - ZM\Logger::Debug("SQL: $sql: rows:" . $result->rowCount()); + ZM\Logger::Debug('SQL: '.$sql.' '.($params?implode(',',$params):'').' rows: '.$result->rowCount()); } } catch(PDOException $e) { ZM\Error("SQL-ERR '".$e->getMessage()."', statement was '".$sql."' params:" . ($params?implode(',',$params):'')); From 0879ecf9a5f3118597264cf68a3b4133956e58da Mon Sep 17 00:00:00 2001 From: Andrew Bauer Date: Mon, 24 Aug 2020 14:33:01 -0500 Subject: [PATCH 08/36] update timeline header --- web/skins/classic/views/js/timeline.js | 27 ++++++++++++++++++++++++++ web/skins/classic/views/timeline.php | 17 ++++++++-------- 2 files changed, 35 insertions(+), 9 deletions(-) diff --git a/web/skins/classic/views/js/timeline.js b/web/skins/classic/views/js/timeline.js index 8742ac67b..85c73baa6 100644 --- a/web/skins/classic/views/js/timeline.js +++ b/web/skins/classic/views/js/timeline.js @@ -214,3 +214,30 @@ window.addEventListener('DOMContentLoaded', function() { }); }); +function initPage() { + var backBtn = $j('#backBtn'); + + // Don't enable the back button if there is no previous zm page to go back to + backBtn.prop('disabled', !document.referrer.length); + + // Manage the BACK button + document.getElementById("backBtn").addEventListener("click", function onBackClick(evt) { + evt.preventDefault(); + window.history.back(); + }); + + // Manage the REFRESH Button + document.getElementById("refreshBtn").addEventListener("click", function onRefreshClick(evt) { + evt.preventDefault(); + window.location.reload(true); + }); + // Manage the LIST Button + document.getElementById("listBtn").addEventListener("click", function onListClick(evt) { + evt.preventDefault(); + window.location.assign('?view=events'+filterQuery); + }); +} + +$j(document).ready(function() { + initPage(); +}); diff --git a/web/skins/classic/views/timeline.php b/web/skins/classic/views/timeline.php index d97713cd7..49233a81f 100644 --- a/web/skins/classic/views/timeline.php +++ b/web/skins/classic/views/timeline.php @@ -673,18 +673,17 @@ $focusWindow = true; xhtmlHeaders(__FILE__, translate('Timeline')); ?> -
-