From 05f0338219f433b9822d49989051f21b84695fd4 Mon Sep 17 00:00:00 2001 From: Isaac Connor Date: Thu, 12 Jul 2018 14:07:19 -0400 Subject: [PATCH] use a unique connection key for downloads --- web/skins/classic/views/download.php | 21 +++++++--- web/skins/classic/views/events.php | 54 ++++++++++++++++---------- web/skins/classic/views/export.php | 10 +++-- web/skins/classic/views/js/download.js | 15 +++++++ web/skins/classic/views/js/events.js | 7 ++-- 5 files changed, 74 insertions(+), 33 deletions(-) diff --git a/web/skins/classic/views/download.php b/web/skins/classic/views/download.php index 06142799c..4d65064a7 100644 --- a/web/skins/classic/views/download.php +++ b/web/skins/classic/views/download.php @@ -24,7 +24,8 @@ if ( !canView('Events') ) { } $total_size = 0; -if (isset($_SESSION['montageReviewFilter'])) { //Handles montageReview filter +if (isset($_SESSION['montageReviewFilter']) and !isset($_REQUEST['eids']) ) { + # Handles montageReview filter $eventsSql = 'SELECT E.Id,E.DiskSpace FROM Events as E WHERE 1'; $eventsSql .= $_SESSION['montageReviewFilter']['sql']; $results = dbQuery($eventsSql); @@ -45,6 +46,7 @@ if (isset($_SESSION['montageReviewFilter'])) { //Handles montageReview filter } $focusWindow = true; +$connkey = isset($_REQUEST['connkey']) ? $_REQUEST['connkey'] : generateConnKey(); xhtmlHeaders(__FILE__, translate('Download') ); ?> @@ -58,23 +60,28 @@ xhtmlHeaders(__FILE__, translate('Download') );
+ DiskSpace() ); } else if ( !empty($_REQUEST['eids']) ) { $total_size = 0; foreach ( $_REQUEST['eids'] as $eid ) { - $Event = new Event($eid); - $total_size += $Event->DiskSpace(); + if ( ! validInt($eid) ) { + Warning("Invalid event id in eids[] $eid"); + continue; + } + $Event = new Event($eid); + $total_size += $Event->DiskSpace(); ?> There are no events found. Resulting download will be empty.
'; @@ -96,7 +103,9 @@ if ( !empty($_REQUEST['eid']) ) { - + - - - - - - - - - - - + + + + + + + + + + + 1 ) { ?> @@ -181,7 +181,7 @@ while ( $event_row = dbFetchNext($results) ) { - + '; } // end if ZM_WEB_LIST_THUMBS ?> - +
- - - - - - - + + + + + + +
0 ) { + Logger::Debug("Loading events by eids"); $eventsSql .= ' AND E.Id IN ('.implode(',', array_map(function(){return '?';}, $_REQUEST['eids'])). ')'; $eventsValues += $_REQUEST['eids']; -} else if ( !empty($_REQUEST['filter']) ) { +} else if ( isset($_REQUEST['filter']) ) { parseSort(); parseFilter($_REQUEST['filter']); $filterQuery = $_REQUEST['filter']['query']; @@ -194,7 +196,7 @@ while ( $event_row = dbFetchNext($results) ) { } if ( !empty($_REQUEST['generated']) ) { ?> - + diff --git a/web/skins/classic/views/js/download.js b/web/skins/classic/views/js/download.js index 493c10566..ef4a652ed 100644 --- a/web/skins/classic/views/js/download.js +++ b/web/skins/classic/views/js/download.js @@ -1,3 +1,18 @@ +function configureExportButton( element ) { + var form = element.form; + + var checkCount = 0; + var radioCount = 0; + for ( var i = 0; i < form.elements.length; i++ ) { + if ( form.elements[i].type == "checkbox" && form.elements[i].checked ) + checkCount++; + else if ( form.elements[i].type == "radio" && form.elements[i].checked ) + radioCount++; + } + form.elements['exportButton'].disabled = (radioCount == 0); + //checkCount == 0 || +} + function startDownload( exportFile ) { window.location.replace( exportFile ); } diff --git a/web/skins/classic/views/js/events.js b/web/skins/classic/views/js/events.js index 2498950fa..007f17456 100644 --- a/web/skins/classic/views/js/events.js +++ b/web/skins/classic/views/js/events.js @@ -97,8 +97,8 @@ function downloadVideo( element, name ) { createPopup( '?view=download&'+eids.join( '&' ), 'zmDownload', 'download' ); } -function exportEvents( element, name ) { - var form = element.form; +function exportEvents(element, name) { + var form = $j(element.form); if ( 0 ) { var eids = new Array(); for (var i = 0; i < form.elements.length; i++) { @@ -110,7 +110,8 @@ function exportEvents( element, name ) { } createPopup( '?view=export&'+eids.join( '&' ), 'zmExport', 'export' ); } - form.action='?view=export'; + form.attr('action', '?view=export'); + form[0].elements['view'].value='export'; form.submit(); }