diff --git a/scripts/ZoneMinder/lib/ZoneMinder/Event.pm b/scripts/ZoneMinder/lib/ZoneMinder/Event.pm index 4f7ce0ca5..404a7b494 100644 --- a/scripts/ZoneMinder/lib/ZoneMinder/Event.pm +++ b/scripts/ZoneMinder/lib/ZoneMinder/Event.pm @@ -32,6 +32,7 @@ require ZoneMinder::Base; require ZoneMinder::Object; require ZoneMinder::Storage; require Date::Manip; +require File; #our @ISA = qw(ZoneMinder::Object); use parent qw(ZoneMinder::Object); @@ -358,6 +359,17 @@ sub age { return $_[0]{age}; } +sub DiskUsage { + if ( @_ > 1 ) { + $_[0]{DiskUsage} = $_[1]; + } + if ( ! defined $_[0]{DiskUsage} ) { + my $size = 0; + File::find( sub { $size += -f $_ ? -s _ : 0 }, $_[0]->Path() ); + $_[0]{DiskUsage} = $size; + } +} + 1; __END__ diff --git a/scripts/zmaudit.pl.in b/scripts/zmaudit.pl.in index a2c666b89..9ccfc2a6e 100644 --- a/scripts/zmaudit.pl.in +++ b/scripts/zmaudit.pl.in @@ -246,6 +246,7 @@ MAIN: while( $loop ) { $$Event{Path} = join('/', $Storage->Path(), $day_dir,$event_path); $Event->MonitorId( $monitor_dir ); $Event->StorageId( $Storage->Id() ); + $Event->DiskUsage( undef ); } # event path exists } # end foreach event_link chdir( $Storage->Path() ); diff --git a/web/includes/Frame.php b/web/includes/Frame.php index 5a31b3dc3..b875ad113 100644 --- a/web/includes/Frame.php +++ b/web/includes/Frame.php @@ -3,7 +3,7 @@ require_once( 'database.php' ); require_once( 'Event.php' ); class Frame { - public function __construct( $IdOrRow ) { + public function __construct( $IdOrRow=null ) { $row = NULL; if ( $IdOrRow ) { if ( is_integer( $IdOrRow ) or ctype_digit($IdOrRow) ) { @@ -17,15 +17,15 @@ class Frame { Error("Unknown argument passed to Frame Constructor ($IdOrRow)"); return; } - } # end if isset($IdOrRow) - if ( $row ) { - foreach ($row as $k => $v) { - $this->{$k} = $v; + if ( $row ) { + foreach ($row as $k => $v) { + $this->{$k} = $v; + } + } else { + Error("No row for Frame " . $IdOrRow ); } - } else { - Error("No row for Frame " . $IdOrRow ); - } + } # end if isset($IdOrRow) } // end function __construct public function Storage() { diff --git a/web/includes/Storage.php b/web/includes/Storage.php index 252be9309..dbc8d7ff9 100644 --- a/web/includes/Storage.php +++ b/web/includes/Storage.php @@ -1,22 +1,22 @@ $v) { $this->{$k} = $v; } - $storage_cache[$IdOrRow] = $this; + #$storage_cache[$IdOrRow] = $this; } else { $this->{'Name'} = ''; $this->{'Path'} = ''; diff --git a/web/skins/classic/views/console.php b/web/skins/classic/views/console.php index 0f67a559f..1beb4bb63 100644 --- a/web/skins/classic/views/console.php +++ b/web/skins/classic/views/console.php @@ -19,6 +19,11 @@ // $servers = Server::find_all(); +$ServersById = array(); +foreach ( $servers as $S ) { + $ServersById[$S->Id()] = $S; +} + $storage_areas = Storage::find_all(); $StorageById = array(); foreach ( $storage_areas as $S ) { @@ -252,7 +257,7 @@ for( $monitor_i = 0; $monitor_i < count($displayMonitors); $monitor_i += 1 ) { '.translate('Fn'.$monitor['Function']).( empty($monitor['Enabled']) ? ', disabled' : '' ) .'', canEdit( 'Monitors' ) ) ?> - Name(); ?> + Name(); ?> MonitorId(), 'zmMonitor'.$event- ?> Path().'/snapshot.jpg' ) ) { + $imgSrc = '?view=image&eid='.$event->Id().'&fid=snapshot&width='.$thumbData['Width'].'&height='.$thumbData['Height']; +} else { $imgSrc = '?view=image&eid='.$event->Id().'&fid='.$thumbData['FrameId'].'&width='.$thumbData['Width'].'&height='.$thumbData['Height']; +} $streamSrc = $event->getStreamSrc( array( 'mode'=>'jpeg', 'scale'=>$scale, 'maxfps'=>ZM_WEB_VIDEO_MAXFPS, 'replay'=>'single') ); $imgHtml = ''. validHtmlStr('Event '.$event->Id()) .''; diff --git a/web/skins/classic/views/js/monitor.js.php b/web/skins/classic/views/js/monitor.js.php index 693f740ab..7e71b7772 100644 --- a/web/skins/classic/views/js/monitor.js.php +++ b/web/skins/classic/views/js/monitor.js.php @@ -50,7 +50,7 @@ monitorNames[''] = true; function validateForm( form ) { var errors = new Array(); - if ( form.elements['newMonitor[Name]'].value.search( /[^\w-\. ]/ ) >= 0 ) + if ( form.elements['newMonitor[Name]'].value.search( /[^\w-\.\(\)\:\/ ]/ ) >= 0 ) errors[errors.length] = ""; else if ( form.elements.mid.value == 0 && monitorNames[form.elements['newMonitor[Name]'].value] ) errors[errors.length] = ""; diff --git a/web/views/image.php b/web/views/image.php index ab15763b3..e7037a9f3 100644 --- a/web/views/image.php +++ b/web/views/image.php @@ -59,21 +59,31 @@ $Event = null; $path = null; if ( empty($_REQUEST['path']) ) { - if ( ! empty($_REQUEST['fid']) ) { - $show = empty($_REQUEST['show']) ? 'capture' : $_REQUEST['show']; - - if ( ! empty($_REQUEST['eid'] ) ) { - $Event = new Event( $_REQUEST['eid'] ); - $Frame = Frame::find_one( array( 'EventId' => $_REQUEST['eid'], 'FrameId' => $_REQUEST['fid'] ) ); - if ( ! $Frame ) { - Fatal("No Frame found for event(".$_REQUEST['eid'].") and frame id(".$_REQUEST['fid'].")"); - } - } else { + + if ( ! empty($_REQUEST['fid']) ) { + if ( $_REQUEST['fid'] == 'snapshot' ) { + $Event = new Event( $_REQUEST['eid'] ); + $Frame = new Frame(); + $Frame->FrameId('snapshot'); + $path = $Event->Path().'/snapshot.jpg'; +Warning("Path to snapshot: $path"); + } else { + + $show = empty($_REQUEST['show']) ? 'capture' : $_REQUEST['show']; + + if ( ! empty($_REQUEST['eid'] ) ) { + $Event = new Event( $_REQUEST['eid'] ); + $Frame = Frame::find_one( array( 'EventId' => $_REQUEST['eid'], 'FrameId' => $_REQUEST['fid'] ) ); + if ( ! $Frame ) { + Fatal("No Frame found for event(".$_REQUEST['eid'].") and frame id(".$_REQUEST['fid'].")"); + } + } else { # If we are only specifying fid, then the fid must be the primary key into the frames table. But when the event is specified, then it is the frame # - $Frame = new Frame( $_REQUEST['fid'] ); - $Event = new Event( $Frame->EventId() ); + $Frame = new Frame( $_REQUEST['fid'] ); + $Event = new Event( $Frame->EventId() ); + } + $path = $Event->Path().'/'.sprintf('%0'.ZM_EVENT_IMAGE_DIGITS.'d',$Frame->FrameId()).'-'.$show.'.jpg'; } - $path = $Event->Path().'/'.sprintf('%0'.ZM_EVENT_IMAGE_DIGITS.'d',$Frame->FrameId()).'-'.$show.'.jpg'; } else { Fatal("No Frame ID specified");