Merge branch 'master' into zma_to_thread

This commit is contained in:
Isaac Connor 2021-01-17 17:38:34 -05:00
commit cb90c06cde
9 changed files with 56 additions and 33 deletions

View File

@ -122,7 +122,17 @@ sub authentificationHeader {
my $nonceBase64 = encode_base64($nonce, ''); my $nonceBase64 = encode_base64($nonce, '');
my $currentDate = DateTime->now()->iso8601().'Z'; my $currentDate = DateTime->now()->iso8601().'Z';
return '<s:Header><Security s:mustUnderstand="1" xmlns="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd"><UsernameToken xmlns="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd"><Username>' . $username . '</Username><Password Type="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordDigest">' . digestBase64($nonce, $currentDate, $password) . '</Password><Nonce EncodingType="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-soap-message-security-1.0#Base64Binary">' . $nonceBase64 . '</Nonce><Created xmlns="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd">' . $currentDate . '</Created></UsernameToken></Security></s:Header>'; return '
<s:Header>
<Security s:mustUnderstand="1" xmlns="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd">
<UsernameToken xmlns="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd">
<Username>' . $username . '</Username>
<Password Type="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordDigest">' . digestBase64($nonce, $currentDate, $password) . '</Password>
<Nonce EncodingType="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-soap-message-security-1.0#Base64Binary">' . $nonceBase64 . '</Nonce>
<Created xmlns="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd">' . $currentDate . '</Created>
</UsernameToken>
</Security>
</s:Header>';
} }
sub sendCmd { sub sendCmd {

View File

@ -65,7 +65,7 @@ sub sendCmd {
my $self = shift; my $self = shift;
my $cmd = shift; my $cmd = shift;
my $result = undef; my $result = undef;
printMsg($cmd, 'Tx'); $this->printMsg($cmd, 'Tx');
my $req = HTTP::Request->new(GET=>'http://'.$self->{Monitor}->{ControlAddress}.'/'.$cmd); my $req = HTTP::Request->new(GET=>'http://'.$self->{Monitor}->{ControlAddress}.'/'.$cmd);
my $res = $self->{ua}->request($req); my $res = $self->{ua}->request($req);

View File

@ -165,8 +165,6 @@ function queryRequest($filter, $search, $advsearch, $sort, $offset, $order, $lim
$col_str = 'E.*, M.Name AS Monitor'; $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; $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(); $storage_areas = ZM\Storage::find();
$StorageById = array(); $StorageById = array();
foreach ( $storage_areas as $S ) { foreach ( $storage_areas as $S ) {
@ -176,14 +174,18 @@ function queryRequest($filter, $search, $advsearch, $sort, $offset, $order, $lim
$unfiltered_rows = array(); $unfiltered_rows = array();
$event_ids = array(); $event_ids = array();
foreach ( dbFetchAll($sql, NULL, $values) as $row ) { ZM\Debug('Calling the following sql query: ' .$sql);
$query = dbQuery($sql, $values);
if ( $query ) {
while ( $row = dbFetchNext($query) ) {
$event = new ZM\Event($row); $event = new ZM\Event($row);
if ( !$filter->test_post_sql_conditions($event) ) {
$event->remove_from_cache(); $event->remove_from_cache();
if ( !$filter->test_post_sql_conditions($event) ) {
continue; continue;
} }
$event_ids[] = $event->Id(); $event_ids[] = $event->Id();
$unfiltered_rows[] = $row; $unfiltered_rows[] = $row;
} # end foreach row
} }
ZM\Debug('Have ' . count($unfiltered_rows) . ' events matching base filter.'); 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 } # 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; $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); $filtered_rows = dbFetchAll($sql);
ZM\Debug('Have ' . count($filtered_rows) . ' events matching search filter.'); ZM\Debug('Have ' . count($filtered_rows) . ' events matching search filter.');
} else { } else {

View File

@ -996,9 +996,8 @@ $OLANG = array(
'Help' => ' 'Help' => '
Parameters in this field are passed on to FFmpeg. Multiple parameters can be separated by ,~~ Parameters in this field are passed on to FFmpeg. Multiple parameters can be separated by ,~~
Examples (do not enter quotes)~~~~ Examples (do not enter quotes)~~~~
"allowed_media_types=video" Set datatype to request fromcam (audio, video, data)~~~~ "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~~~~ "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)
' '
), ),
'OPTIONS_ENCODER_PARAMETERS' => array( 'OPTIONS_ENCODER_PARAMETERS' => array(

View File

@ -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) { function human_filesize(size, precision = 2) {
var units = Array('B', 'kB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB'); var units = Array('B', 'kB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB');
var step = 1024; var step = 1024;

View File

@ -43,7 +43,7 @@ var serverId = '<?php echo defined('ZM_SERVER_ID') ? ZM_SERVER_ID : '' ?>';
var canView = {}; var canView = {};
var canEdit = {}; var canEdit = {};
<?php <?php
$perms = array("Stream", "Events", "Control", "Monitors", "Groups", "System", "Devices"); $perms = array('Stream', 'Events', 'Control', 'Monitors', 'Groups', 'System', 'Devices');
foreach ( $perms as $perm ) { foreach ( $perms as $perm ) {
?> ?>
canView["<?php echo $perm ?>"] = <?php echo canView($perm)?'true':'false' ?>; canView["<?php echo $perm ?>"] = <?php echo canView($perm)?'true':'false' ?>;
@ -60,7 +60,7 @@ if ( ! empty($refreshParent) ) {
echo 'true'; echo 'true';
} else if ( $refreshParent ) { } else if ( $refreshParent ) {
# This is to tell the parent to refresh to a specific URL # This is to tell the parent to refresh to a specific URL
echo "'$refreshParent'"; echo '\''.$refreshParent.'\'';
} else { } else {
echo 'false'; echo 'false';
} }

View File

@ -1035,14 +1035,14 @@ function initPage() {
}); });
// Manage the FRAMES Button // Manage the FRAMES Button
document.getElementById("framesBtn").addEventListener("click", function onFramesClick(evt) { bindButton('#framesBtn', 'click', null, function onFramesClick(evt) {
evt.preventDefault(); evt.preventDefault();
window.location.assign('?view=frames&eid='+eventData.Id); window.location.assign('?view=frames&eid='+eventData.Id);
}); });
// Manage the DELETE button // Manage the DELETE button
document.getElementById("deleteBtn").addEventListener("click", function onDeleteClick(evt) { bindButton('#deleteBtn', 'click', null, function onDeleteClick(evt) {
if ( ! canEdit.Events ) { if ( !canEdit.Events ) {
enoperm(); enoperm();
return; return;
} }
@ -1061,7 +1061,7 @@ function initPage() {
} }
$j('#deleteConfirm').modal('show'); $j('#deleteConfirm').modal('show');
}); });
} } // end initPage
// Kick everything off // Kick everything off
$j(document).ready(initPage); $j(document).ready(initPage);

View File

@ -118,7 +118,7 @@ function requestFrameData( eventId, frameId ) {
function previewEvent(slot) { function previewEvent(slot) {
eventId = slot.getAttribute('data-event-id'); eventId = slot.getAttribute('data-event-id');
frameId = slot.getAttribute('data-frame-id'); frameId = slot.getAttribute('data-frame-id');
if ( events[eventId] ) { if ( events[eventId] && events[eventId]['frames'] && events[eventId]['frames'][frameId] ) {
showEventData(eventId, frameId); showEventData(eventId, frameId);
} else { } else {
requestFrameData(eventId, frameId); requestFrameData(eventId, frameId);

View File

@ -40,6 +40,7 @@ function ajaxRequest(params) {
params.data.order = 'desc'; params.data.order = 'desc';
params.data.limit = maxDisplayEvents; params.data.limit = maxDisplayEvents;
params.data.sort = 'Id'; params.data.sort = 'Id';
if ( auth_hash ) params.data.auth = auth_hash;
$j.getJSON(thisUrl + '?view=request&request=events&task=query'+filterQuery, params.data) $j.getJSON(thisUrl + '?view=request&request=events&task=query'+filterQuery, params.data)
.done(function(data) { .done(function(data) {
@ -290,8 +291,8 @@ function getStreamCmdResponse(respObj, respText) {
// Try to reload the image stream. // Try to reload the image stream.
// If it's an auth error, we should reload the whole page. // If it's an auth error, we should reload the whole page.
console.log("have error"); console.log("have error");
window.location.reload(); //window.location.reload();
if ( 0 ) { if ( 1 ) {
var streamImg = $j('#liveStream'+monitorId); var streamImg = $j('#liveStream'+monitorId);
if ( streamImg ) { if ( streamImg ) {
var oldSrc = streamImg.attr('src'); var oldSrc = streamImg.attr('src');
@ -359,7 +360,7 @@ function streamCmdPlay( action ) {
} }
function streamCmdReq(data) { 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) .done(getStreamCmdResponse)
.fail(getStreamCmdError); .fail(getStreamCmdError);
@ -527,7 +528,7 @@ function getStatusCmdResponse(respObj, respText) {
} }
function statusCmdQuery() { 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) .done(getStatusCmdResponse)
.fail(logAjaxFail); .fail(logAjaxFail);
@ -535,7 +536,7 @@ function statusCmdQuery() {
} }
function alarmCmdReq(data) { 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) .done(getAlarmCmdResponse)
.fail(function(jqxhr, textStatus, error) { .fail(function(jqxhr, textStatus, error) {
if (textstatus === "timeout") { if (textstatus === "timeout") {
@ -598,7 +599,7 @@ function cmdForce() {
} }
function controlReq(data) { 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) .done(getControlResponse)
.fail(logAjaxFail); .fail(logAjaxFail);
} }
@ -758,7 +759,7 @@ function updatePresetLabels() {
} }
function getCtrlPresetModal() { function getCtrlPresetModal() {
$j.getJSON(thisUrl + '?request=modal&modal=controlpreset&mid=' + monitorId) $j.getJSON(monitorUrl + '?request=modal&modal=controlpreset&mid=' + monitorId)
.done(function(data) { .done(function(data) {
insertModalHtml('ctrlPresetModal', data.html); insertModalHtml('ctrlPresetModal', data.html);
updatePresetLabels(); updatePresetLabels();
@ -774,7 +775,7 @@ function getCtrlPresetModal() {
} }
function getSettingsModal() { function getSettingsModal() {
$j.getJSON(thisUrl + '?request=modal&modal=settings&mid=' + monitorId) $j.getJSON(monitorUrl + '?request=modal&modal=settings&mid=' + monitorId)
.done(function(data) { .done(function(data) {
insertModalHtml('settingsModal', data.html); insertModalHtml('settingsModal', data.html);
// Manage the Save button // Manage the Save button
@ -788,7 +789,7 @@ function getSettingsModal() {
function processClicks(event, field, value, row, $element) { function processClicks(event, field, value, row, $element) {
if ( field == 'Delete' ) { if ( field == 'Delete' ) {
$j.getJSON(thisUrl + '?request=modal&modal=delconfirm') $j.getJSON(monitorUrl + '?request=modal&modal=delconfirm')
.done(function(data) { .done(function(data) {
insertModalHtml('deleteConfirm', data.html); insertModalHtml('deleteConfirm', data.html);
manageDelConfirmModalBtns(); manageDelConfirmModalBtns();
@ -886,7 +887,7 @@ function initPage() {
} }
// Manage the BACK button // Manage the BACK button
document.getElementById("backBtn").addEventListener("click", function onBackClick(evt) { bindButton('#backBtn', 'click', null, function onBackClick(evt) {
evt.preventDefault(); evt.preventDefault();
window.history.back(); window.history.back();
}); });
@ -895,13 +896,13 @@ function initPage() {
backBtn.prop('disabled', !document.referrer.length); backBtn.prop('disabled', !document.referrer.length);
// Manage the REFRESH Button // Manage the REFRESH Button
document.getElementById("refreshBtn").addEventListener("click", function onRefreshClick(evt) { bindButton('#refreshBtn', 'click', null, function onRefreshClick(evt) {
evt.preventDefault(); evt.preventDefault();
window.location.reload(true); window.location.reload(true);
}); });
// Manage the SETTINGS button // Manage the SETTINGS button
document.getElementById("settingsBtn").addEventListener("click", function onSettingsClick(evt) { bindButton('settingsBtn', 'click', null, function onSettingsClick(evt) {
evt.preventDefault(); evt.preventDefault();
$j('#settingsModal').modal('show'); $j('#settingsModal').modal('show');
}); });