diff --git a/scripts/ZoneMinder/lib/ZoneMinder/ConfigData.pm.in b/scripts/ZoneMinder/lib/ZoneMinder/ConfigData.pm.in index 063630ed0..1924d3576 100644 --- a/scripts/ZoneMinder/lib/ZoneMinder/ConfigData.pm.in +++ b/scripts/ZoneMinder/lib/ZoneMinder/ConfigData.pm.in @@ -1550,6 +1550,19 @@ our @options = ( type => $types{string}, category => "web", }, + { + name => 'ZM_WEB_EVENT_DISK_SPACE', + default => '', + description => "Whether to show disk space used by each event.", + help => qqq("Adds another column to the listing of events + showing the disk space used by the event. This will impart a small + overhead as it will call du on the event directory. In practice + this overhead is fairly small but may be noticeable on IO-constrained + systems. + "), + type => $types{string}, + category => "web", + }, { name => "ZM_WEB_RESIZE_CONSOLE", default => "yes", diff --git a/web/includes/Event.php b/web/includes/Event.php index 36125165a..3b7a1e5e0 100644 --- a/web/includes/Event.php +++ b/web/includes/Event.php @@ -148,5 +148,8 @@ public function getStreamSrc( $args, $querySep='&' ) { return( $streamSrc ); } // end function getStreamSrc + function DiskSpace() { + return folder_size( $this->Path() ); + } } # end class ?> diff --git a/web/includes/functions.php b/web/includes/functions.php index 1344f03fa..f386bee51 100644 --- a/web/includes/functions.php +++ b/web/includes/functions.php @@ -2131,4 +2131,12 @@ function getStreamHTML( $monitor, $scale=100 ) { } } // end function getStreamHTML +function folder_size($dir) { + $size = 0; + foreach (glob(rtrim($dir, '/').'/*', GLOB_NOSORT) as $each) { + $size += is_file($each) ? filesize($each) : folderSize($each); + } + return $size; +} // end fucntion folder_size + ?> diff --git a/web/skins/classic/views/events.php b/web/skins/classic/views/events.php index b7d707b22..e090617d0 100644 --- a/web/skins/classic/views/events.php +++ b/web/skins/classic/views/events.php @@ -30,7 +30,7 @@ if ( !empty($_REQUEST['execute']) ) } $countSql = 'SELECT count(E.Id) AS EventCount FROM Monitors AS M INNER JOIN Events AS E ON (M.Id = E.MonitorId) WHERE'; -$eventsSql = 'SELECT E.Id,E.MonitorId,M.Name AS MonitorName,M.DefaultScale,E.Name,E.Width,E.Height,E.Cause,E.Notes,E.StartTime,E.Length,E.Frames,E.AlarmFrames,E.TotScore,E.AvgScore,E.MaxScore,E.Archived FROM Monitors AS M INNER JOIN Events AS E on (M.Id = E.MonitorId) WHERE'; +$eventsSql = 'SELECT E.*,M.Name AS MonitorName FROM Monitors AS M INNER JOIN Events AS E on (M.Id = E.MonitorId) WHERE'; if ( $user['MonitorIds'] ) { $user_monitor_ids = ' M.Id in ('.$user['MonitorIds'].')'; $countSql .= $user_monitor_ids; @@ -95,8 +95,10 @@ $unarchived = false; $events = array(); foreach ( dbFetchAll( $eventsSql ) as $event ) { - $events[] = $event; - $scale = max( reScale( SCALE_BASE, $event['DefaultScale'], ZM_WEB_DEFAULT_SCALE ), SCALE_BASE ); + $events[] = new Event( $event ); + + # Doesn this code do anything? + $scale = max( reScale( SCALE_BASE, $event->DefaultScale(), ZM_WEB_DEFAULT_SCALE ), SCALE_BASE ); $eventWidth = reScale( $event['Width'], $scale ); $eventHeight = reScale( $event['Height'], $scale ); if ( $maxWidth < $eventWidth ) $maxWidth = $eventWidth; @@ -183,7 +185,10 @@ foreach ( $events as $event ) + + @@ -195,27 +200,30 @@ foreach ( $events as $event ) DefaultScale(), ZM_WEB_DEFAULT_SCALE ), SCALE_BASE ); ?> - - - - - - - - - - - + Id().$filterQuery.$sortQuery.'&page=1', 'zmEvent', array( 'event', reScale( $event->Width(), $scale ), reScale( $event->Height(), $scale ) ), $event->Id().($event->Archived()?'*':'') ) ?> + Id().$filterQuery.$sortQuery.'&page=1', 'zmEvent', array( 'event', reScale( $event->Width(), $event->DefaultScale(), ZM_WEB_DEFAULT_SCALE ), reScale( $event->Height(), $event->DefaultScale(), ZM_WEB_DEFAULT_SCALE ) ), validHtmlStr($event->Name()).($event->Archived()?'*':'' ) ) ?> + MonitorName() ?> + Id(), 'zmEventDetail', 'eventdetail', validHtmlStr($event->Cause()), canEdit( 'Events' ), 'title="'.htmlspecialchars($event->Notes()).'"' ) ?> + StartTime()) ) ?> + Length() ) ?> + Id(), 'zmFrames', 'frames', $event->Frames() ) ?> + Id(), 'zmFrames', 'frames', $event->AlarmFrames() ) ?> + TotScore() ?> + AvgScore() ?> + Id().'&fid=0', 'zmImage', array( 'image', reScale( $event->Width(), $scale ), reScale( $event->Height(), $scale ) ), $event->MaxScore() ) ?> + + DiskSpace() ?> - ' ) ?> + Id().'&fid='.$thumbData['FrameId'], 'zmImage', array( 'image', reScale( $event->Width(), $scale ), reScale( $event->Height(), $scale ) ), ''.$thumbData['FrameId'].'/'.$event->MaxScore().'' ) ?> - disabled="disabled"/> + disabled="disabled"/>