2017-12-04 03:04:33 +08:00
|
|
|
<?php
|
|
|
|
//
|
|
|
|
// ZoneMinder web export view file, $Date$, $Revision$
|
|
|
|
// Copyright (C) 2001-2008 Philip Coombes
|
|
|
|
//
|
|
|
|
// This program is free software; you can redistribute it and/or
|
|
|
|
// modify it under the terms of the GNU General Public License
|
|
|
|
// as published by the Free Software Foundation; either version 2
|
|
|
|
// of the License, or (at your option) any later version.
|
|
|
|
//
|
|
|
|
// This program is distributed in the hope that it will be useful,
|
|
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
// GNU General Public License for more details.
|
|
|
|
//
|
|
|
|
// You should have received a copy of the GNU General Public License
|
|
|
|
// along with this program; if not, write to the Free Software
|
|
|
|
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
|
|
|
//
|
|
|
|
|
2017-12-05 00:05:50 +08:00
|
|
|
if ( !canView('Events') ) {
|
2017-12-04 03:04:33 +08:00
|
|
|
$view = 'error';
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2017-12-12 06:33:17 +08:00
|
|
|
$total_size = 0;
|
2019-03-21 02:25:12 +08:00
|
|
|
if ( isset($_SESSION['montageReviewFilter']) and !isset($_REQUEST['eids']) ) {
|
2018-07-13 02:07:19 +08:00
|
|
|
# Handles montageReview filter
|
2019-07-25 00:31:43 +08:00
|
|
|
$eventsSql = 'SELECT E.Id, E.DiskSpace FROM Events AS E WHERE 1';
|
2017-12-04 11:25:17 +08:00
|
|
|
$eventsSql .= $_SESSION['montageReviewFilter']['sql'];
|
2017-12-04 03:04:33 +08:00
|
|
|
$results = dbQuery($eventsSql);
|
|
|
|
$eids = [];
|
|
|
|
while ( $event_row = dbFetchNext( $results ) ) {
|
2019-03-21 02:51:59 +08:00
|
|
|
array_push($eids, $event_row['Id']);
|
2017-12-12 06:33:17 +08:00
|
|
|
$total_size += $event_row['DiskSpace'];
|
2017-12-04 03:04:33 +08:00
|
|
|
}
|
|
|
|
$_REQUEST['eids'] = $eids;
|
2017-12-12 06:33:17 +08:00
|
|
|
if ( ! count($eids) ) {
|
2019-03-21 02:25:12 +08:00
|
|
|
ZM\Error("No events found for download using $eventsSql");
|
2017-12-12 06:33:17 +08:00
|
|
|
}
|
|
|
|
#session_start();
|
|
|
|
#unset($_SESSION['montageReviewFilter']);
|
|
|
|
#session_write_close();
|
|
|
|
#} else {
|
|
|
|
#Logger::Debug("NO montageReviewFilter");
|
2017-12-04 03:04:33 +08:00
|
|
|
}
|
|
|
|
|
2019-02-09 17:16:32 +08:00
|
|
|
$exportFormat = '';
|
2019-03-21 02:25:12 +08:00
|
|
|
if ( isset($_REQUEST['exportFormat']) ) {
|
|
|
|
if ( !in_array($_REQUEST['exportFormat'], array('zip', 'tar')) ) {
|
2019-07-25 00:31:43 +08:00
|
|
|
ZM\Error('Invalid exportFormat: '.$_REQUEST['exportFormat']);
|
|
|
|
} else {
|
|
|
|
$exportFormat = $_REQUEST['exportFormat'];
|
2019-02-09 17:16:32 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-03-21 02:25:12 +08:00
|
|
|
if ( !empty($_REQUEST['eid']) ) {
|
2019-03-21 02:51:59 +08:00
|
|
|
$Event = new ZM\Event($_REQUEST['eid']);
|
2019-03-21 02:25:12 +08:00
|
|
|
if ( !$Event->Id ) {
|
2019-02-09 17:37:32 +08:00
|
|
|
Error('Invalid event id');
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-12-04 03:04:33 +08:00
|
|
|
$focusWindow = true;
|
2018-07-13 02:07:19 +08:00
|
|
|
$connkey = isset($_REQUEST['connkey']) ? $_REQUEST['connkey'] : generateConnKey();
|
2017-12-04 03:04:33 +08:00
|
|
|
|
2019-03-21 02:25:12 +08:00
|
|
|
xhtmlHeaders(__FILE__, translate('Download'));
|
2017-12-04 03:04:33 +08:00
|
|
|
?>
|
|
|
|
<body>
|
|
|
|
<div id="page">
|
|
|
|
<div id="header">
|
|
|
|
<div id="headerButtons">
|
2019-01-16 22:59:58 +08:00
|
|
|
<a href="#" data-on-click="closeWindow"><?php echo translate('Close') ?></a>
|
2017-12-04 03:04:33 +08:00
|
|
|
</div>
|
|
|
|
<h2><?php echo translate('Download') ?></h2>
|
|
|
|
</div>
|
|
|
|
<div id="content">
|
|
|
|
<form name="contentForm" id="contentForm" method="post" action="<?php echo $_SERVER['PHP_SELF'] ?>">
|
2018-07-13 02:07:19 +08:00
|
|
|
<input type="hidden" name="connkey" value="<?php echo $connkey; ?>"/>
|
2017-12-04 03:04:33 +08:00
|
|
|
<?php
|
2017-12-05 00:05:50 +08:00
|
|
|
if ( !empty($_REQUEST['eid']) ) {
|
2017-12-04 03:04:33 +08:00
|
|
|
?>
|
|
|
|
<input type="hidden" name="id" value="<?php echo validInt($_REQUEST['eid']) ?>"/>
|
2017-12-12 06:33:17 +08:00
|
|
|
<?php
|
2019-03-21 02:25:12 +08:00
|
|
|
$Event = new ZM\Event($_REQUEST['eid']);
|
2019-02-09 17:37:32 +08:00
|
|
|
echo 'Downloading event ' . $Event->Id . '. Resulting file should be approximately ' . human_filesize( $Event->DiskSpace() );
|
2017-12-05 00:05:50 +08:00
|
|
|
} else if ( !empty($_REQUEST['eids']) ) {
|
2018-05-18 21:51:42 +08:00
|
|
|
$total_size = 0;
|
2017-12-05 00:05:50 +08:00
|
|
|
foreach ( $_REQUEST['eids'] as $eid ) {
|
2018-07-13 02:07:19 +08:00
|
|
|
if ( ! validInt($eid) ) {
|
2019-03-21 02:25:12 +08:00
|
|
|
ZM\Warning("Invalid event id in eids[] $eid");
|
2018-07-13 02:07:19 +08:00
|
|
|
continue;
|
|
|
|
}
|
2019-03-21 02:51:59 +08:00
|
|
|
$Event = new ZM\Event($eid);
|
2018-07-13 02:07:19 +08:00
|
|
|
$total_size += $Event->DiskSpace();
|
2017-12-04 03:04:33 +08:00
|
|
|
?>
|
|
|
|
<input type="hidden" name="eids[]" value="<?php echo validInt($eid) ?>"/>
|
|
|
|
<?php
|
|
|
|
}
|
2018-07-13 02:07:19 +08:00
|
|
|
unset($eid);
|
2017-12-12 06:33:17 +08:00
|
|
|
echo "Downloading " . count($_REQUEST['eids']) . ' events. Resulting file should be approximately ' . human_filesize($total_size);
|
|
|
|
} else {
|
2018-05-18 21:51:42 +08:00
|
|
|
echo '<div class="warning">There are no events found. Resulting download will be empty.</div>';
|
2017-12-04 03:04:33 +08:00
|
|
|
}
|
|
|
|
?>
|
2019-03-21 02:51:59 +08:00
|
|
|
<table id="contentTable" class="minor">
|
2017-12-04 03:04:33 +08:00
|
|
|
<tbody>
|
|
|
|
<tr>
|
|
|
|
<td><input type="hidden" name="exportVideo" value="1"/></td>
|
|
|
|
</tr>
|
|
|
|
<tr>
|
|
|
|
<th scope="row"><?php echo translate('ExportFormat') ?></th>
|
|
|
|
<td>
|
2019-02-09 17:16:32 +08:00
|
|
|
<input type="radio" id="exportFormatTar" name="exportFormat" value="tar"/>
|
2017-12-05 00:05:50 +08:00
|
|
|
<label for="exportFormatTar"><?php echo translate('ExportFormatTar') ?></label>
|
2019-02-09 17:16:32 +08:00
|
|
|
<input type="radio" id="exportFormatZip" name="exportFormat" value="zip" checked="checked"/>
|
2017-12-05 00:05:50 +08:00
|
|
|
<label for="exportFormatZip"><?php echo translate('ExportFormatZip') ?></label>
|
2017-12-04 03:04:33 +08:00
|
|
|
</td>
|
|
|
|
</tr>
|
|
|
|
</tbody>
|
|
|
|
</table>
|
2019-07-25 00:31:43 +08:00
|
|
|
<button type="button" id="exportButton" name="exportButton" value="GenerateDownload">
|
|
|
|
<!--data-on-click-this="exportEvent">-->
|
2018-07-13 02:07:19 +08:00
|
|
|
<?php echo translate('GenerateDownload') ?>
|
|
|
|
</button>
|
2017-12-04 03:04:33 +08:00
|
|
|
</form>
|
|
|
|
</div>
|
|
|
|
<?php
|
2017-12-05 00:05:50 +08:00
|
|
|
if ( isset($_REQUEST['generated']) ) {
|
2017-12-04 03:04:33 +08:00
|
|
|
?>
|
2017-12-05 00:05:50 +08:00
|
|
|
<h2 id="exportProgress" class="<?php echo $_REQUEST['generated']?'infoText':'errorText' ?>">
|
|
|
|
<span id="exportProgressText"><?php echo $_REQUEST['generated']?translate('ExportSucceeded'):translate('ExportFailed') ?></span>
|
|
|
|
<span id="exportProgressTicker"></span>
|
|
|
|
</h2>
|
2017-12-04 03:04:33 +08:00
|
|
|
<?php
|
2017-12-05 00:05:50 +08:00
|
|
|
} else {
|
2017-12-04 03:04:33 +08:00
|
|
|
?>
|
2017-12-05 00:05:50 +08:00
|
|
|
<h2 id="exportProgress" class="hidden warnText">
|
|
|
|
<span id="exportProgressText"><?php echo translate('Exporting') ?></span>
|
|
|
|
<span id="exportProgressTicker"></span>
|
|
|
|
</h2>
|
2017-12-04 03:04:33 +08:00
|
|
|
<?php
|
|
|
|
}
|
2017-12-05 00:05:50 +08:00
|
|
|
if ( !empty($_REQUEST['generated']) ) {
|
2017-12-04 03:04:33 +08:00
|
|
|
?>
|
2019-02-09 17:37:32 +08:00
|
|
|
<h3 id="downloadLink"><a href="?view=archive&type=<?php echo $exportFormat; ?>"><?php echo translate('Download') ?></a></h3>
|
2017-12-04 03:04:33 +08:00
|
|
|
<?php
|
|
|
|
}
|
|
|
|
?>
|
|
|
|
</div>
|
|
|
|
</body>
|
|
|
|
</html>
|