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 { sub age {
if ( ! $_[0]{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))); $_[0]{age} = (time() - ($^T - ((-M $_[0]->Path() ) * 24*60*60)));
} else {
Warning($_[0]->Path() . ' does not appear to exist.');
}
} }
return $_[0]{age}; return $_[0]{age};
} }

View File

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

View File

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

View File

@ -283,7 +283,9 @@ for ( $i = 0; $i < $pointCols; $i++ )
</tr> </tr>
</tbody> </tbody>
</table> </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> </div>
</form> </form>
</div> </div>

View File

@ -71,8 +71,7 @@ xhtmlHeaders(__FILE__, translate('Zones') );
</thead> </thead>
<tbody> <tbody>
<?php <?php
foreach( $zones as $zone ) foreach( $zones as $zone ) {
{
?> ?>
<tr> <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> <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>