add Event disk space recalc to zmaudit
parent
ffc1ac43f5
commit
7f50a13074
|
@ -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__
|
||||
|
||||
|
|
|
@ -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() );
|
||||
|
|
|
@ -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() {
|
||||
|
|
|
@ -1,22 +1,22 @@
|
|||
<?php
|
||||
require_once( 'database.php' );
|
||||
|
||||
$storage_cache = array();
|
||||
#$storage_cache = array();
|
||||
class Storage {
|
||||
public function __construct( $IdOrRow = NULL ) {
|
||||
$row = NULL;
|
||||
if ( $IdOrRow ) {
|
||||
if ( is_integer( $IdOrRow ) or is_numeric( $IdOrRow ) ) {
|
||||
|
||||
if ( isset( $storage_cache[$IdOrRow] ) ) {
|
||||
Logger::Debug("Using cached Storage object for $IdOrRow");
|
||||
return $storage_cache[$IdOrRow];
|
||||
} else {
|
||||
#if ( isset( $storage_cache[$IdOrRow] ) ) {
|
||||
#Warning("using cached object for $dOrRow");
|
||||
#return $storage_cache[$IdOrRow];
|
||||
#} else {
|
||||
#Warning("Not using cached object for $dOrRow");
|
||||
$row = dbFetchOne( 'SELECT * FROM Storage WHERE Id=?', NULL, array( $IdOrRow ) );
|
||||
if ( ! $row ) {
|
||||
Error("Unable to load Storage record for Id=" . $IdOrRow );
|
||||
}
|
||||
}
|
||||
} elseif ( is_array( $IdOrRow ) ) {
|
||||
$row = $IdOrRow;
|
||||
}
|
||||
|
@ -25,7 +25,7 @@ Logger::Debug("Using cached Storage object for $IdOrRow");
|
|||
foreach ($row as $k => $v) {
|
||||
$this->{$k} = $v;
|
||||
}
|
||||
$storage_cache[$IdOrRow] = $this;
|
||||
#$storage_cache[$IdOrRow] = $this;
|
||||
} else {
|
||||
$this->{'Name'} = '';
|
||||
$this->{'Path'} = '';
|
||||
|
|
|
@ -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 ) {
|
|||
<td class="colFunction"><?php echo makePopupLink( '?view=function&mid='.$monitor['Id'], 'zmFunction', 'function', '<span class="'.$fclass.'">'.translate('Fn'.$monitor['Function']).( empty($monitor['Enabled']) ? ', disabled' : '' ) .'</span>', canEdit( 'Monitors' ) ) ?></td>
|
||||
<?php
|
||||
if ( count($servers) ) { ?>
|
||||
<td class="colServer"><?php $Server = new Server( $monitor['ServerId'] ); echo $Server->Name(); ?></td>
|
||||
<td class="colServer"><?php $Server = isset($ServersById[$monitor['ServerId']]) ? $ServersById[$monitor['ServerId']] : new Server( $monitor['ServerId'] ); echo $Server->Name(); ?></td>
|
||||
<?php
|
||||
}
|
||||
$source = '';
|
||||
|
|
|
@ -215,7 +215,11 @@ makePopupLink( '?view=monitor&mid='.$event->MonitorId(), 'zmMonitor'.$event-
|
|||
?>
|
||||
<td class="colThumbnail">
|
||||
<?php
|
||||
if ( file_exists( $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 = '<img id="thumbnail'.$event->id().'" src="'.$imgSrc.'" alt="'. validHtmlStr('Event '.$event->Id()) .'" style="width:'. validInt($thumbData['Width']) .'px;height:'. validInt( $thumbData['Height'] ).'px;" onmouseover="this.src=\''.$streamSrc.'\';" onmouseout="this.src=\''.$imgSrc.'\';"/>';
|
||||
|
|
|
@ -50,7 +50,7 @@ monitorNames['<?php echo validJsStr($name) ?>'] = 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] = "<?php echo translate('BadNameChars') ?>";
|
||||
else if ( form.elements.mid.value == 0 && monitorNames[form.elements['newMonitor[Name]'].value] )
|
||||
errors[errors.length] = "<?php echo translate('DuplicateMonitorName') ?>";
|
||||
|
|
|
@ -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");
|
||||
|
|
Loading…
Reference in New Issue