Merge sjc04p1fviap02.teslamotors.com:ZoneMinder into storageareas
This commit is contained in:
commit
9cbcc43e3d
|
@ -1,7 +1,7 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
class Event {
|
class Event {
|
||||||
public function __construct( $IdOrRow ) {
|
public function __construct( $IdOrRow = null ) {
|
||||||
$row = NULL;
|
$row = NULL;
|
||||||
if ( $IdOrRow ) {
|
if ( $IdOrRow ) {
|
||||||
if ( is_integer( $IdOrRow ) or is_numeric( $IdOrRow ) ) {
|
if ( is_integer( $IdOrRow ) or is_numeric( $IdOrRow ) ) {
|
||||||
|
@ -19,15 +19,18 @@ class Event {
|
||||||
Error("Unknown argument passed to Event Constructor ($IdOrRow)");
|
Error("Unknown argument passed to Event Constructor ($IdOrRow)");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
} # end if isset($IdOrRow)
|
|
||||||
|
|
||||||
if ( $row ) {
|
if ( $row ) {
|
||||||
foreach ($row as $k => $v) {
|
foreach ($row as $k => $v) {
|
||||||
$this->{$k} = $v;
|
$this->{$k} = $v;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
Error('No row for Event ' . $IdOrRow );
|
$backTrace = debug_backtrace();
|
||||||
|
$file = $backTrace[1]['file'];
|
||||||
|
$line = $backTrace[1]['line'];
|
||||||
|
Error('No row for Event ' . $IdOrRow . " from $file:$line");
|
||||||
}
|
}
|
||||||
|
} # end if isset($IdOrRow)
|
||||||
} // end function __construct
|
} // end function __construct
|
||||||
|
|
||||||
public function Storage() {
|
public function Storage() {
|
||||||
|
@ -163,11 +166,11 @@ class Event {
|
||||||
} // end function getStreamSrc
|
} // end function getStreamSrc
|
||||||
|
|
||||||
function DiskSpace() {
|
function DiskSpace() {
|
||||||
if ( null == $this{'DiskSpace'} ) {
|
if ( null == $this->{'DiskSpace'} ) {
|
||||||
$this{'DiskSpace'} = folder_size( $this->Path() );
|
$this->{'DiskSpace'} = folder_size( $this->Path() );
|
||||||
dbQuery( 'UPDATE Events SET DiskSpace=? WHERE Id=?', array( $this->{'DiskSpace'}, $this->{'Id'} ) );
|
dbQuery( 'UPDATE Events SET DiskSpace=? WHERE Id=?', array( $this->{'DiskSpace'}, $this->{'Id'} ) );
|
||||||
}
|
}
|
||||||
return $this{'DiskSpace'};
|
return $this->{'DiskSpace'};
|
||||||
}
|
}
|
||||||
|
|
||||||
function createListThumbnail( $overwrite=false ) {
|
function createListThumbnail( $overwrite=false ) {
|
||||||
|
|
|
@ -1,14 +1,21 @@
|
||||||
<?php
|
<?php
|
||||||
require_once( 'database.php' );
|
require_once( 'database.php' );
|
||||||
|
|
||||||
|
$storage_cache = array();
|
||||||
class Storage {
|
class Storage {
|
||||||
public function __construct( $IdOrRow = NULL ) {
|
public function __construct( $IdOrRow = NULL ) {
|
||||||
$row = NULL;
|
$row = NULL;
|
||||||
if ( $IdOrRow ) {
|
if ( $IdOrRow ) {
|
||||||
if ( is_integer( $IdOrRow ) or is_numeric( $IdOrRow ) ) {
|
if ( is_integer( $IdOrRow ) or is_numeric( $IdOrRow ) ) {
|
||||||
|
|
||||||
|
if ( isset( $storage_cache[$IdOrRow] ) ) {
|
||||||
|
return $storage_cache[$IdOrRow];
|
||||||
|
} else {
|
||||||
$row = dbFetchOne( 'SELECT * FROM Storage WHERE Id=?', NULL, array( $IdOrRow ) );
|
$row = dbFetchOne( 'SELECT * FROM Storage WHERE Id=?', NULL, array( $IdOrRow ) );
|
||||||
if ( ! $row ) {
|
if ( ! $row ) {
|
||||||
Error("Unable to load Storage record for Id=" . $IdOrRow );
|
Error("Unable to load Storage record for Id=" . $IdOrRow );
|
||||||
}
|
}
|
||||||
|
}
|
||||||
} elseif ( is_array( $IdOrRow ) ) {
|
} elseif ( is_array( $IdOrRow ) ) {
|
||||||
$row = $IdOrRow;
|
$row = $IdOrRow;
|
||||||
}
|
}
|
||||||
|
@ -17,6 +24,7 @@ class Storage {
|
||||||
foreach ($row as $k => $v) {
|
foreach ($row as $k => $v) {
|
||||||
$this->{$k} = $v;
|
$this->{$k} = $v;
|
||||||
}
|
}
|
||||||
|
$storage_cache[$IdOrRow] = $this;
|
||||||
} else {
|
} else {
|
||||||
$this->{'Name'} = '';
|
$this->{'Name'} = '';
|
||||||
$this->{'Path'} = '';
|
$this->{'Path'} = '';
|
||||||
|
|
|
@ -127,10 +127,10 @@ function dbQuery( $sql, $params=NULL ) {
|
||||||
} else {
|
} else {
|
||||||
$result = $dbConn->query( $sql );
|
$result = $dbConn->query( $sql );
|
||||||
}
|
}
|
||||||
//if ( $params )
|
if ( $params )
|
||||||
//Warning("SQL: $sql" . implode(',',$params));
|
Warning("SQL: $sql" . implode(',',$params));
|
||||||
//else
|
else
|
||||||
//Warning("SQL: $sql" );
|
Warning("SQL: $sql" );
|
||||||
} catch(PDOException $e) {
|
} catch(PDOException $e) {
|
||||||
Fatal( "SQL-ERR '".$e->getMessage()."', statement was '".$sql."'" );
|
Fatal( "SQL-ERR '".$e->getMessage()."', statement was '".$sql."'" );
|
||||||
}
|
}
|
||||||
|
|
|
@ -2197,7 +2197,7 @@ function getStreamMode( ) {
|
||||||
function folder_size($dir) {
|
function folder_size($dir) {
|
||||||
$size = 0;
|
$size = 0;
|
||||||
foreach (glob(rtrim($dir, '/').'/*', GLOB_NOSORT) as $each) {
|
foreach (glob(rtrim($dir, '/').'/*', GLOB_NOSORT) as $each) {
|
||||||
$size += is_file($each) ? filesize($each) : folderSize($each);
|
$size += is_file($each) ? filesize($each) : folder_size($each);
|
||||||
}
|
}
|
||||||
return $size;
|
return $size;
|
||||||
} // end function folder_size
|
} // end function folder_size
|
||||||
|
|
Loading…
Reference in New Issue