Merge branch 'storageareas' of github.com:connortechnology/ZoneMinder into storageareas

pull/2077/head
Isaac Connor 2017-10-04 21:51:38 -04:00
commit 91c2e07e64
6 changed files with 139 additions and 141 deletions

View File

@ -348,7 +348,12 @@ Debug("Checking for files for event $_[0]{Id} at $path using glob $path/* found
sub age {
if ( ! $_[0]{age} ) {
if ( -e $_[0]->Path() ) {
# $^T is the time the program began running. -M is program start time - file modification time in days
$_[0]{age} = (time() - ($^T - ((-M $_[0]->Path() ) * 24*60*60)));
} else {
Warning($_[0]->Path() . ' does not appear to exist.');
}
}
return $_[0]{age};
}

View File

@ -3,23 +3,19 @@
define( "MSG_TIMEOUT", ZM_WEB_AJAX_TIMEOUT );
define( "MSG_DATA_SIZE", 4+256 );
if ( !($_REQUEST['connkey'] && $_REQUEST['command']) )
{
if ( !($_REQUEST['connkey'] && $_REQUEST['command']) ) {
ajaxError( "Unexpected received message type '$type'" );
}
if ( !($socket = @socket_create( AF_UNIX, SOCK_DGRAM, 0 )) )
{
if ( !($socket = @socket_create( AF_UNIX, SOCK_DGRAM, 0 )) ) {
ajaxError( "socket_create() failed: ".socket_strerror(socket_last_error()) );
}
$locSockFile = ZM_PATH_SOCKS.'/zms-'.sprintf("%06d",$_REQUEST['connkey']).'w.sock';
if ( !@socket_bind( $socket, $locSockFile ) )
{
if ( !@socket_bind( $socket, $locSockFile ) ) {
ajaxError( "socket_bind( $locSockFile ) failed: ".socket_strerror(socket_last_error()) );
}
switch ( $_REQUEST['command'] )
{
switch ( $_REQUEST['command'] ) {
case CMD_VARPLAY :
Logger::Debug( "Varplaying to ".$_REQUEST['rate'] );
$msg = pack( "lcn", MSG_CMD, $_REQUEST['command'], $_REQUEST['rate']+32768 );
@ -64,26 +60,18 @@ $wSockets = NULL;
$eSockets = NULL;
$numSockets = @socket_select( $rSockets, $wSockets, $eSockets, intval(MSG_TIMEOUT/1000), (MSG_TIMEOUT%1000)*1000 );
if ( $numSockets === false )
{
if ( $numSockets === false ) {
ajaxError( "socket_select failed: ".socket_strerror(socket_last_error()) );
}
else if ( $numSockets < 0 )
{
} else if ( $numSockets < 0 ) {
ajaxError( "Socket closed $remSockFile" );
}
else if ( $numSockets == 0 )
{
} else if ( $numSockets == 0 ) {
ajaxError( "Timed out waiting for msg $remSockFile" );
}
else if ( $numSockets > 0 )
{
} else if ( $numSockets > 0 ) {
if ( count($rSockets) != 1 )
ajaxError( "Bogus return from select, ".count($rSockets)." sockets available" );
}
switch( $nbytes = @socket_recvfrom( $socket, $msg, MSG_DATA_SIZE, 0, $remSockFile ) )
{
switch( $nbytes = @socket_recvfrom( $socket, $msg, MSG_DATA_SIZE, 0, $remSockFile ) ) {
case -1 :
{
ajaxError( "socket_recvfrom( $remSockFile ) failed: ".socket_strerror(socket_last_error()) );
@ -103,8 +91,7 @@ switch( $nbytes = @socket_recvfrom( $socket, $msg, MSG_DATA_SIZE, 0, $remSockFil
}
$data = unpack( "ltype", $msg );
switch ( $data['type'] )
{
switch ( $data['type'] ) {
case MSG_DATA_WATCH :
{
$data = unpack( "ltype/imonitor/istate/dfps/ilevel/irate/ddelay/izoom/Cdelayed/Cpaused/Cenabled/Cforced", $msg );
@ -150,8 +137,7 @@ switch ( $data['type'] )
ajaxError( 'Unrecognised action or insufficient permissions' );
function ajaxCleanup()
{
function ajaxCleanup() {
global $socket, $locSockFile;
if ( !empty( $socket ) )
@socket_close( $socket );

View File

@ -496,16 +496,20 @@ function getStreamCmdResponse( respObj, respText ) {
}
} else {
checkStreamForErrors("getStreamCmdResponse", respObj);//log them
if ( ! streamPause ) {
// Try to reload the image stream.
var streamImg = document.getElementById('liveStream');
var streamImg = $('liveStream'+monitorId);
if ( streamImg )
streamImg.src = streamImg.src.replace(/rand=\d+/i, 'rand='+Math.floor((Math.random() * 1000000) ));
}
}
if ( ! streamPause ) {
var streamCmdTimeout = statusRefreshTimeout;
if ( alarmState == STATE_ALARM || alarmState == STATE_ALERT )
streamCmdTimeout = streamCmdTimeout/5;
streamCmdTimer = streamCmdQuery.delay( streamCmdTimeout );
}
}
var streamPause = false;
@ -556,10 +560,12 @@ function getStatusCmdResponse( respObj, respText ) {
} else
checkStreamForErrors("getStatusCmdResponse", respObj);
if ( ! streamPause ) {
var statusCmdTimeout = statusRefreshTimeout;
if ( alarmState == STATE_ALARM || alarmState == STATE_ALERT )
statusCmdTimeout = statusCmdTimeout/5;
statusCmdTimer = statusCmdQuery.delay( statusCmdTimeout );
}
}
function statusCmdQuery() {

View File

@ -283,7 +283,9 @@ for ( $i = 0; $i < $pointCols; $i++ )
</tr>
</tbody>
</table>
<input id="pauseBtn" type="button" value="<?php echo translate('Pause') ?>" onclick="streamCmdPauseToggle()"/><input type="submit" id="submitBtn" name="submitBtn" value="<?php echo translate('Save') ?>" onclick="return saveChanges( this )"<?php if (!canEdit( 'Monitors' ) || (false && $selfIntersecting)) { ?> disabled="disabled"<?php } ?>/><input type="button" value="<?php echo translate('Cancel') ?>" onclick="refreshParentWindow(); closeWindow();"/>
<input id="pauseBtn" type="button" value="<?php echo translate('Pause') ?>" onclick="streamCmdPauseToggle()"/>
<input type="submit" id="submitBtn" name="submitBtn" value="<?php echo translate('Save') ?>" onclick="return saveChanges( this )"<?php if (!canEdit( 'Monitors' ) || (false && $selfIntersecting)) { ?> disabled="disabled"<?php } ?>/>
<input type="button" value="<?php echo translate('Cancel') ?>" onclick="refreshParentWindow(); closeWindow();"/>
</div>
</form>
</div>

View File

@ -26,10 +26,10 @@ if ( !canView( 'Monitors' ) ) {
$mid = validInt($_REQUEST['mid']);
$monitor = new Monitor( $mid );
# Width() and Height() are already rotated
$minX = 0;
$maxX = $monitor->Width()-1;
$minY = 0;
$maxY = $monitor->Height()-1;
$minX = 0;
$maxX = $monitor->Width()-1;
$minY = 0;
$maxY = $monitor->Height()-1;
$zones = array();
foreach( dbFetchAll( 'SELECT * FROM Zones WHERE MonitorId=? ORDER BY Area DESC', NULL, array($mid) ) as $row ) {
@ -71,8 +71,7 @@ xhtmlHeaders(__FILE__, translate('Zones') );
</thead>
<tbody>
<?php
foreach( $zones as $zone )
{
foreach( $zones as $zone ) {
?>
<tr>
<td class="colName"><a href="#" onclick="streamCmdQuit( true ); createPopup( '?view=zone&amp;mid=<?php echo $mid ?>&amp;zid=<?php echo $zone['Id'] ?>', 'zmZone', 'zone', <?php echo $monitor->Width() ?>, <?php echo $monitor->Height() ?> ); return( false );"><?php echo $zone['Name'] ?></a></td>