Change COnfig from using the subroutine symbol table to just using a global hash

This commit is contained in:
Isaac Connor 2013-12-16 16:32:02 -05:00
parent 263f3a6e02
commit 48a6dcf5ce
14 changed files with 382 additions and 383 deletions

View File

@ -33,6 +33,7 @@ require ZoneMinder::Base;
our @ISA = qw(Exporter ZoneMinder::Base);
use vars qw( %Config );
# Items to export into callers namespace by default. Note: do not export
# names by default without a very good reason. Use EXPORT_OK instead.
# Do not simply export all your public functions/methods/constants.
@ -40,7 +41,7 @@ our @ISA = qw(Exporter ZoneMinder::Base);
# This allows declaration use ZoneMinder ':all';
# If you do not need this, moving things directly into @EXPORT or @EXPORT_OK
# will save memory.
our @EXPORT_CONFIG; # Get populated by BEGIN
our @EXPORT_CONFIG = qw( %Config ); # Get populated by BEGIN
our %EXPORT_TAGS = (
'constants' => [ qw(
@ -64,11 +65,9 @@ use Carp;
# Load the config from the database into the symbol table
BEGIN
{
no strict 'refs';
my $config_file = ZM_CONFIG;
( my $local_config_file = $config_file ) =~ s|^.*/|./|;
if ( -s $local_config_file && -r $local_config_file )
if ( -s $local_config_file and -r $local_config_file )
{
print( STDERR "Warning, overriding installed $local_config_file file with local copy\n" );
$config_file = $local_config_file;
@ -84,23 +83,20 @@ BEGIN
next;
} # end if
$name =~ tr/a-z/A-Z/;
*{$name} = sub { $value };
push( @EXPORT_CONFIG, $name );
$Config{$name} = $value;
}
close( CONFIG );
use DBI;
my $dbh = DBI->connect( "DBI:mysql:database=".&ZM_DB_NAME.";host=".&ZM_DB_HOST, &ZM_DB_USER, &ZM_DB_PASS );
my $sql = "select * from Config";
my $dbh = DBI->connect( "DBI:mysql:database=".$Config{ZM_DB_NAME}.";host=".$Config{ZM_DB_HOST}, $Config{ZM_DB_USER}, $Config{ZM_DB_PASS} ) or croak( "Can't connect to db" );
my $sql = 'select * from Config';
my $sth = $dbh->prepare_cached( $sql ) or croak( "Can't prepare '$sql': ".$dbh->errstr() );
my $res = $sth->execute() or croak( "Can't execute: ".$sth->errstr() );
while( my $config = $sth->fetchrow_hashref() )
{
*{$config->{Name}} = sub { $config->{Value} };
push( @EXPORT_CONFIG, $config->{Name} );
while( my $config = $sth->fetchrow_hashref() ) {
$Config{$config->{Name}} = $config->{Value};
}
$sth->finish();
$dbh->disconnect();
#$dbh->disconnect();
}
1;

View File

@ -68,7 +68,7 @@ use Carp;
sub loadConfigFromDB
{
print( "Loading config from DB\n" );
my $dbh = DBI->connect( "DBI:mysql:database=".ZM_DB_NAME.";host=".ZM_DB_HOST, ZM_DB_USER, ZM_DB_PASS );
my $dbh = DBI->connect( "DBI:mysql:database=".$Config{ZM_DB_NAME}.";host=".$Config{ZM_DB_HOST}, $Config{ZM_DB_USER}, $Config{ZM_DB_PASS} );
if ( !$dbh )
{
@ -111,13 +111,19 @@ sub loadConfigFromDB
sub saveConfigToDB
{
print( "Saving config to DB\n" );
my $dbh = DBI->connect( "DBI:mysql:database=".ZM_DB_NAME.";host=".ZM_DB_HOST, ZM_DB_USER, ZM_DB_PASS );
my $dbh = DBI->connect( "DBI:mysql:database=".$Config{ZM_DB_NAME}.";host=".$Config{ZM_DB_HOST}, $Config{ZM_DB_USER}, $Config{ZM_DB_PASS} );
if ( !$dbh )
{
print( "Error: unable to save options to database: $DBI::errstr\n" );
return( 0 );
}
my $ac = $dbh->{AutoCommit};
$dbh->{AutoCommit} = 0;
$dbh->do('LOCK TABLE Config WRITE') or croak( "Can't lock Config table: " . $dbh->errstr() );
my $sql = "delete from Config";
my $res = $dbh->do( $sql ) or croak( "Can't do '$sql': ".$dbh->errstr() );
@ -149,6 +155,10 @@ sub saveConfigToDB
my $res = $sth->execute( $option->{id}, $option->{name}, $option->{db_value}, $option->{db_type}, $option->{default}, $option->{db_hint}, $option->{db_pattern}, $option->{db_format}, $option->{description}, $option->{help}, $option->{category}, $option->{readonly}?1:0, $option->{db_requires} ) or croak( "Can't execute: ".$sth->errstr() );
}
$sth->finish();
$dbh->do('UNLOCK TABLES');
$dbh->{AutoCommit} = $ac;
$dbh->disconnect();
}

View File

@ -79,15 +79,15 @@ sub zmDbConnect( ;$ )
}
if ( !defined( $dbh ) )
{
my ( $host, $port ) = ( ZM_DB_HOST =~ /^([^:]+)(?::(.+))?$/ );
my ( $host, $port ) = ( $Config{ZM_DB_HOST} =~ /^([^:]+)(?::(.+))?$/ );
if ( defined($port) )
{
$dbh = DBI->connect( "DBI:mysql:database=".ZM_DB_NAME.";host=".$host.";port=".$port, ZM_DB_USER, ZM_DB_PASS );
$dbh = DBI->connect( "DBI:mysql:database=".$Config{ZM_DB_NAME}.";host=".$host.";port=".$port, $Config{ZM_DB_USER}, $Config{ZM_DB_PASS} );
}
else
{
$dbh = DBI->connect( "DBI:mysql:database=".ZM_DB_NAME.";host=".ZM_DB_HOST, ZM_DB_USER, ZM_DB_PASS );
$dbh = DBI->connect( "DBI:mysql:database=".$Config{ZM_DB_NAME}.";host=".$Config{ZM_DB_HOST}, $Config{ZM_DB_USER}, $Config{ZM_DB_PASS} );
}
$dbh->trace( 0 );
}

View File

@ -95,7 +95,7 @@ sub getCmdFormat()
Debug( "Testing valid shell syntax\n" );
my ( $name ) = getpwuid( $> );
if ( $name eq ZM_WEB_USER )
if ( $name eq $Config{ZM_WEB_USER} )
{
Debug( "Running as '$name', su commands not needed\n" );
return( "" );
@ -103,7 +103,7 @@ sub getCmdFormat()
my $null_command = "true";
my $prefix = "sudo -u ".ZM_WEB_USER." ";
my $prefix = "sudo -u ".$Config{ZM_WEB_USER}." ";
my $suffix = "";
my $command = $prefix.$null_command.$suffix;
Debug( "Testing \"$command\"\n" );
@ -120,7 +120,7 @@ sub getCmdFormat()
chomp( $output );
Debug( "Test failed, '$output'\n" );
$prefix = "su ".ZM_WEB_USER." --shell=/bin/sh --command='";
$prefix = "su ".$Config{ZM_WEB_USER}." --shell=/bin/sh --command='";
$suffix = "'";
$command = $prefix.$null_command.$suffix;
Debug( "Testing \"$command\"\n" );
@ -136,7 +136,7 @@ sub getCmdFormat()
chomp( $output );
Debug( "Test failed, '$output'\n" );
$prefix = "su ".ZM_WEB_USER." -c '";
$prefix = "su ".$Config{ZM_WEB_USER}." -c '";
$suffix = "'";
$command = $prefix.$null_command.$suffix;
Debug( "Testing \"$command\"\n" );
@ -172,7 +172,7 @@ sub runCommand( $ )
}
my $command = shift;
$command = ZM_PATH_BIN."/".$command;
$command = $Config{ZM_PATH_BIN}."/".$command;
if ( $cmdPrefix )
{
$command = $cmdPrefix.$command.$cmdSuffix;
@ -201,15 +201,15 @@ sub getEventPath( $ )
my $event = shift;
my $event_path = "";
if ( ZM_USE_DEEP_STORAGE )
if ( $Config{ZM_USE_DEEP_STORAGE} )
{
$event_path = ZM_DIR_EVENTS.'/'.$event->{MonitorId}.'/'.strftime( "%y/%m/%d/%H/%M/%S", localtime($event->{Time}) );
$event_path = $Config{ZM_DIR_EVENTS}.'/'.$event->{MonitorId}.'/'.strftime( "%y/%m/%d/%H/%M/%S", localtime($event->{Time}) );
}
else
{
$event_path = ZM_DIR_EVENTS.'/'.$event->{MonitorId}.'/'.$event->{Id};
$event_path = $Config{ZM_DIR_EVENTS}.'/'.$event->{MonitorId}.'/'.$event->{Id};
}
$event_path = ZM_PATH_WEB.'/'.$event_path if ( index(ZM_DIR_EVENTS,'/') != 0 );
$event_path = $Config{ZM_PATH_WEB}.'/'.$event_path if ( index($Config{ZM_DIR_EVENTS},'/') != 0 );
return( $event_path );
}
@ -219,10 +219,10 @@ sub createEventPath( $ )
# WARNING assumes running from events directory
#
my $event = shift;
my $eventRootPath = (ZM_DIR_EVENTS=~m|/|)?ZM_DIR_EVENTS:(ZM_PATH_WEB.'/'.ZM_DIR_EVENTS);
my $eventRootPath = ($Config{ZM_DIR_EVENTS}=~m|/|)?$Config{ZM_DIR_EVENTS}:($Config{ZM_PATH_WEB}.'/'.$Config{ZM_DIR_EVENTS});
my $eventPath = $eventRootPath.'/'.$event->{MonitorId};
if ( ZM_USE_DEEP_STORAGE )
if ( $Config{ZM_USE_DEEP_STORAGE} )
{
my @startTime = localtime( $event->{StartTime} );
@ -277,10 +277,10 @@ sub _checkProcessOwner()
if ( !defined($_setFileOwner) )
{
my ( $processOwner ) = getpwuid( $> );
if ( $processOwner ne ZM_WEB_USER )
if ( $processOwner ne $Config{ZM_WEB_USER} )
{
# Not running as web user, so should be root in whch case chown the temporary directory
( my $ownerName, my $ownerPass, $_ownerUid, $_ownerGid ) = getpwnam( ZM_WEB_USER ) or Fatal( "Can't get user details for web user '".ZM_WEB_USER."': $!" );
( my $ownerName, my $ownerPass, $_ownerUid, $_ownerGid ) = getpwnam( $Config{ZM_WEB_USER} ) or Fatal( "Can't get user details for web user '".$Config{ZM_WEB_USER}."': $!" );
$_setFileOwner = 1;
}
else
@ -297,7 +297,7 @@ sub setFileOwner( $ )
if ( _checkProcessOwner() )
{
chown( $_ownerUid, $_ownerGid, $file ) or Fatal( "Can't change ownership of file '$file' to '".ZM_WEB_USER.":".ZM_WEB_GROUP."': $!" );
chown( $_ownerUid, $_ownerGid, $file ) or Fatal( "Can't change ownership of file '$file' to '".$Config{ZM_WEB_USER}.":".$Config{ZM_WEB_GROUP}."': $!" );
}
}
@ -434,12 +434,12 @@ sub createEvent( $;$ )
#$frame->{FrameId} = $dbh->{mysql_insertid};
if ( $frame->{imagePath} )
{
$frame->{capturePath} = sprintf( "%s/%0".ZM_EVENT_IMAGE_DIGITS."d-capture.jpg", $eventPath, $frame->{FrameId} );
$frame->{capturePath} = sprintf( "%s/%0".$Config{ZM_EVENT_IMAGE_DIGITS}."d-capture.jpg", $eventPath, $frame->{FrameId} );
rename( $frame->{imagePath}, $frame->{capturePath} ) or Fatal( "Can't copy ".$frame->{imagePath}." to ".$frame->{capturePath}.": $!" );
setFileOwner( $frame->{capturePath} );
if ( 0 && ZM_CREATE_ANALYSIS_IMAGES )
if ( 0 && $Config{ZM_CREATE_ANALYSIS_IMAGES} )
{
$frame->{analysePath} = sprintf( "%s/%0".ZM_EVENT_IMAGE_DIGITS."d-analyse.jpg", $eventPath, $frame->{FrameId} );
$frame->{analysePath} = sprintf( "%s/%0".$Config{ZM_EVENT_IMAGE_DIGITS}."d-analyse.jpg", $eventPath, $frame->{FrameId} );
link( $frame->{capturePath}, $frame->{analysePath} ) or Fatal( "Can't link ".$frame->{capturePath}." to ".$frame->{analysePath}.": $!" );
setFileOwner( $frame->{analysePath} );
}
@ -497,7 +497,7 @@ sub deleteEventFiles( $;$ )
my $monitor_id = shift;
$monitor_id = '*' if ( !defined($monitor_id) );
if ( ZM_USE_DEEP_STORAGE )
if ( $Config{ZM_USE_DEEP_STORAGE} )
{
my $link_path = $monitor_id."/*/*/*/.".$event_id;
#Debug( "LP1:$link_path" );

View File

@ -150,7 +150,7 @@ sub new
$this->{hasTerm} = -t STDERR;
( $this->{fileName} = $0 ) =~ s|^.*/||;
$this->{logPath} = ZM_PATH_LOGS;
$this->{logPath} = $Config{ZM_PATH_LOGS};
$this->{logFile} = $this->{logPath}."/".$this->{id}.".log";
$this->{trace} = 0;
@ -163,7 +163,7 @@ sub BEGIN
{
# Fake the config variables that are used in case they are not defined yet
# Only really necessary to support upgrade from previous version
if ( !eval('defined(ZM_LOG_DEBUG)') )
if ( !eval('defined($Config{ZM_LOG_DEBUG})') )
{
no strict 'subs';
no strict 'refs';
@ -221,7 +221,7 @@ sub initialise( @ )
}
else
{
$tempDatabaseLevel = ZM_LOG_LEVEL_DATABASE;
$tempDatabaseLevel = $Config{ZM_LOG_LEVEL_DATABASE};
}
if ( defined($options{fileLevel}) )
{
@ -229,7 +229,7 @@ sub initialise( @ )
}
else
{
$tempFileLevel = ZM_LOG_LEVEL_FILE;
$tempFileLevel = $Config{ZM_LOG_LEVEL_FILE};
}
if ( defined($options{syslogLevel}) )
{
@ -237,7 +237,7 @@ sub initialise( @ )
}
else
{
$tempSyslogLevel = ZM_LOG_LEVEL_SYSLOG;
$tempSyslogLevel = $Config{ZM_LOG_LEVEL_SYSLOG};
}
if ( defined($ENV{'LOG_PRINT'}) )
@ -253,18 +253,18 @@ sub initialise( @ )
$tempFileLevel = $level if ( defined($level = $this->getTargettedEnv('LOG_LEVEL_FILE')) );
$tempSyslogLevel = $level if ( defined($level = $this->getTargettedEnv('LOG_LEVEL_SYSLOG')) );
if ( ZM_LOG_DEBUG )
if ( $Config{ZM_LOG_DEBUG} )
{
foreach my $target ( split( /\|/, ZM_LOG_DEBUG_TARGET ) )
foreach my $target ( split( /\|/, $Config{ZM_LOG_DEBUG_TARGET} ) )
{
if ( $target eq $this->{id} || $target eq "_".$this->{id} || $target eq $this->{idRoot} || $target eq "_".$this->{idRoot} || $target eq "" )
{
if ( ZM_LOG_DEBUG_LEVEL > NOLOG )
if ( $Config{ZM_LOG_DEBUG_LEVEL} > NOLOG )
{
$tempLevel = $this->limit( ZM_LOG_DEBUG_LEVEL );
if ( ZM_LOG_DEBUG_FILE ne "" )
$tempLevel = $this->limit( $Config{ZM_LOG_DEBUG_LEVEL} );
if ( $Config{ZM_LOG_DEBUG_FILE} ne "" )
{
$tempLogFile = ZM_LOG_DEBUG_FILE;
$tempLogFile = $Config{ZM_LOG_DEBUG_FILE};
$tempFileLevel = $tempLevel;
}
}
@ -447,20 +447,20 @@ sub databaseLevel( ;$ )
{
if ( !$this->{dbh} )
{
my ( $host, $port ) = ( ZM_DB_HOST =~ /^([^:]+)(?::(.+))?$/ );
my ( $host, $port ) = ( $Config{ZM_DB_HOST} =~ /^([^:]+)(?::(.+))?$/ );
if ( defined($port) )
{
$this->{dbh} = DBI->connect( "DBI:mysql:database=".ZM_DB_NAME.";host=".$host.";port=".$port, ZM_DB_USER, ZM_DB_PASS );
$this->{dbh} = DBI->connect( "DBI:mysql:database=".$Config{ZM_DB_NAME}.";host=".$host.";port=".$port, $Config{ZM_DB_USER}, $Config{ZM_DB_PASS} );
}
else
{
$this->{dbh} = DBI->connect( "DBI:mysql:database=".ZM_DB_NAME.";host=".ZM_DB_HOST, ZM_DB_USER, ZM_DB_PASS );
$this->{dbh} = DBI->connect( "DBI:mysql:database=".$Config{ZM_DB_NAME}.";host=".$Config{ZM_DB_HOST}, $Config{ZM_DB_USER}, $Config{ZM_DB_PASS} );
}
if ( !$this->{dbh} )
{
$databaseLevel = NOLOG;
Error( "Unable to write log entries to DB, can't connect to database '".ZM_DB_NAME."' on host '".ZM_DB_HOST."'" );
Error( "Unable to write log entries to DB, can't connect to database '".$Config{ZM_DB_NAME}."' on host '".$Config{ZM_DB_HOST}."'" );
}
else
{
@ -553,8 +553,8 @@ sub openFile()
{
LOGFILE->autoflush() if ( $this->{autoFlush} );
my $webUid = (getpwnam( ZM_WEB_USER ))[2];
my $webGid = (getgrnam( ZM_WEB_GROUP ))[2];
my $webUid = (getpwnam( $Config{ZM_WEB_USER} ))[2];
my $webGid = (getgrnam( $Config{ZM_WEB_GROUP} ))[2];
if ( $> == 0 )
{
chown( $webUid, $webGid, $this->{logFile} ) or Fatal( "Can't change permissions on log file '".$this->{logFile}."': $!" )

View File

@ -57,8 +57,8 @@ use File::Find;
use Time::HiRes qw/gettimeofday/;
use Getopt::Long;
use constant IMAGE_PATH => ZM_PATH_WEB.'/'.ZM_DIR_IMAGES;
use constant EVENT_PATH => (ZM_DIR_EVENTS=~m|/|)?ZM_DIR_EVENTS:(ZM_PATH_WEB.'/'.ZM_DIR_EVENTS);
use constant IMAGE_PATH => $Config{ZM_PATH_WEB}.'/'.$Config{ZM_DIR_IMAGES};
use constant EVENT_PATH => ($Config{ZM_DIR_EVENTS}=~m|/|)?$Config{ZM_DIR_EVENTS}:($Config{ZM_PATH_WEB}.'/'.$Config{ZM_DIR_EVENTS});
$| = 1;
@ -107,7 +107,7 @@ chdir( EVENT_PATH );
my $max_image_age = 6/24; # 6 hours
my $max_swap_age = 24/24; # 24 hours
my $image_path = IMAGE_PATH;
my $swap_image_path = ZM_PATH_SWAP;
my $swap_image_path = $Config{ZM_PATH_SWAP};
my $loop = 1;
my $cleaned = 0;
@ -142,7 +142,7 @@ MAIN: while( $loop )
my $fs_events = $fs_monitors->{$monitor} = {};
( my $monitor_dir ) = ( $monitor =~ /^(.*)$/ ); # De-taint
if ( ZM_USE_DEEP_STORAGE )
if ( $Config{ZM_USE_DEEP_STORAGE} )
{
foreach my $day_dir ( <$monitor_dir/*/*/*> )
{
@ -399,9 +399,9 @@ MAIN: while( $loop )
File::Find::find( { wanted=>\&deleteSwapImage, untaint=>1 }, $swap_image_root );
# Prune the Logs table if required
if ( ZM_LOG_DATABASE_LIMIT )
if ( $Config{ZM_LOG_DATABASE_LIMIT} )
{
if ( ZM_LOG_DATABASE_LIMIT =~ /^\d+$/ )
if ( $Config{ZM_LOG_DATABASE_LIMIT} =~ /^\d+$/ )
{
# Number of rows
my $selectLogRowCountSql = "select count(*) as Rows from Logs";
@ -410,18 +410,18 @@ MAIN: while( $loop )
my $row = $selectLogRowCountSth->fetchrow_hashref();
my $logRows = $row->{Rows};
$selectLogRowCountSth->finish();
if ( $logRows > ZM_LOG_DATABASE_LIMIT )
if ( $logRows > $Config{ZM_LOG_DATABASE_LIMIT} )
{
my $deleteLogByRowsSql = "delete low_priority from Logs order by TimeKey asc limit ?";
my $deleteLogByRowsSth = $dbh->prepare_cached( $deleteLogByRowsSql ) or Fatal( "Can't prepare '$deleteLogByRowsSql': ".$dbh->errstr() );
$res = $deleteLogByRowsSth->execute( $logRows - ZM_LOG_DATABASE_LIMIT ) or Fatal( "Can't execute: ".$deleteLogByRowsSth->errstr() );
$res = $deleteLogByRowsSth->execute( $logRows - $Config{ZM_LOG_DATABASE_LIMIT} ) or Fatal( "Can't execute: ".$deleteLogByRowsSth->errstr() );
aud_print( "Deleted ".$deleteLogByRowsSth->rows()." log table entries by count\n" ) if ( $deleteLogByRowsSth->rows() );
}
}
else
{
# Time of record
my $deleteLogByTimeSql = "delete low_priority from Logs where TimeKey < unix_timestamp(now() - interval ".ZM_LOG_DATABASE_LIMIT.")";
my $deleteLogByTimeSql = "delete low_priority from Logs where TimeKey < unix_timestamp(now() - interval ".$Config{ZM_LOG_DATABASE_LIMIT}.")";
my $deleteLogByTimeSth = $dbh->prepare_cached( $deleteLogByTimeSql ) or Fatal( "Can't prepare '$deleteLogByTimeSql': ".$dbh->errstr() );
$res = $deleteLogByTimeSth->execute() or Fatal( "Can't execute: ".$deleteLogByTimeSth->errstr() );
aud_print( "Deleted ".$deleteLogByTimeSth->rows()." log table entries by time\n" ) if ( $deleteLogByTimeSth->rows() );
@ -429,7 +429,7 @@ MAIN: while( $loop )
}
$loop = $continuous;
sleep( ZM_AUDIT_CHECK_INTERVAL ) if ( $continuous );
sleep( $Config{ZM_AUDIT_CHECK_INTERVAL} ) if $continuous;
};
exit( 0 );

View File

@ -88,7 +88,7 @@ if ( !$id || !$options{command} )
Debug( $arg_string );
my $sock_file = ZM_PATH_SOCKS.'/zmcontrol-'.$id.'.sock';
my $sock_file = $Config{ZM_PATH_SOCKS}.'/zmcontrol-'.$id.'.sock';
socket( CLIENT, PF_UNIX, SOCK_STREAM, 0 ) or Fatal( "Can't open socket: $!" );

View File

@ -51,7 +51,7 @@ use Socket;
use IO::Handle;
use Data::Dumper;
use constant SOCK_FILE => ZM_PATH_SOCKS.'/zmdc.sock';
use constant SOCK_FILE => $Config{ZM_PATH_SOCKS}.'/zmdc.sock';
$| = 1;
@ -437,7 +437,7 @@ sub start
if ( $daemon =~ /^${daemon_patt}$/ )
{
$daemon = ZM_PATH_BIN.'/'.$1;
$daemon = $Config{ZM_PATH_BIN}.'/'.$1;
}
else
{
@ -645,7 +645,7 @@ sub reaper
if ( $process->{keepalive} )
{
if ( !$process->{delay} || ($process->{runtime} > ZM_MAX_RESTART_DELAY) )
if ( !$process->{delay} || ($process->{runtime} > $Config{ZM_MAX_RESTART_DELAY} ) )
{
#start( $process->{daemon}, @{$process->{args}} );
# Schedule for immediate restart
@ -659,9 +659,9 @@ sub reaper
$process->{pending} = $process->{stopped}+$process->{delay};
$process->{delay} *= 2;
# Limit the start delay to 15 minutes max
if ( $process->{delay} > ZM_MAX_RESTART_DELAY )
if ( $process->{delay} > $Config{ZM_MAX_RESTART_DELAY} )
{
$process->{delay} = ZM_MAX_RESTART_DELAY;
$process->{delay} = $Config{ZM_MAX_RESTART_DELAY};
}
}
}

View File

@ -56,11 +56,11 @@ use constant EVENT_PATH => (ZM_DIR_EVENTS=~m|/|)?ZM_DIR_EVENTS:(ZM_PATH_WEB.'/'.
logInit();
logSetSignal();
if ( ZM_OPT_UPLOAD )
if ( $Config{ZM_OPT_UPLOAD} )
{
# Comment these out if you don't have them and don't want to upload
# or don't want to use that format
if ( ZM_UPLOAD_ARCH_FORMAT eq "zip" )
if ( $Config{ZM_UPLOAD_ARCH_FORMAT} eq "zip" )
{
require Archive::Zip;
import Archive::Zip qw( :ERROR_CODES :CONSTANTS );
@ -69,7 +69,7 @@ if ( ZM_OPT_UPLOAD )
{
require Archive::Tar;
}
if ( ZM_UPLOAD_PROTOCOL eq "ftp" )
if ( $Config{ZM_UPLOAD_PROTOCOL} eq "ftp" )
{
require Net::FTP;
}
@ -79,9 +79,9 @@ if ( ZM_OPT_UPLOAD )
}
}
if ( ZM_OPT_EMAIL )
if ( $Config{ZM_OPT_EMAIL} )
{
if ( ZM_NEW_MAIL_MODULES )
if ( $Config{ZM_NEW_MAIL_MODULES} )
{
require MIME::Lite;
require Net::SMTP;
@ -92,9 +92,9 @@ if ( ZM_OPT_EMAIL )
}
}
if ( ZM_OPT_MESSAGE )
if ( $Config{ZM_OPT_MESSAGE} )
{
if ( ZM_NEW_MAIL_MODULES )
if ( $Config{ZM_NEW_MAIL_MODULES} )
{
require MIME::Lite;
require Net::SMTP;
@ -112,7 +112,7 @@ $ENV{PATH} = '/bin:/usr/bin';
$ENV{SHELL} = '/bin/sh' if exists $ENV{SHELL};
delete @ENV{qw(IFS CDPATH ENV BASH_ENV)};
my $delay = ZM_FILTER_EXECUTE_INTERVAL;
my $delay = $Config{ZM_FILTER_EXECUTE_INTERVAL};
my $event_id = 0;
my $filter_parm = "";
@ -163,7 +163,7 @@ if ( !GetOptions( 'filter=s'=>\$filter_parm ) )
Usage();
}
chdir( EVENT_PATH );
chdir( $Config{EVENT_PATH} );
my $dbh = zmDbConnect();
@ -178,7 +178,7 @@ else
if ( !$filter_parm )
{
sleep( START_DELAY );
sleep( $Config{START_DELAY} );
}
my $filters;
@ -186,7 +186,7 @@ my $last_action = 0;
while( 1 )
{
if ( (time() - $last_action) > ZM_FILTER_RELOAD_DELAY )
if ( (time() - $last_action) > $Config{ZM_FILTER_RELOAD_DELAY} )
{
Debug( "Reloading filters\n" );
$last_action = time();
@ -573,28 +573,28 @@ sub checkFilter
my $sth = $dbh->prepare_cached( $sql ) or Fatal( "Can't prepare '$sql': ".$dbh->errstr() );
my $res = $sth->execute( $event->{Id} ) or Fatal( "Can't execute '$sql': ".$sth->errstr() );
}
if ( ZM_OPT_FFMPEG && $filter->{AutoVideo} )
if ( $Config{ZM_OPT_FFMPEG} && $filter->{AutoVideo} )
{
if ( !$event->{Videoed} )
{
$delete_ok = undef if ( !generateVideo( $filter, $event ) );
}
}
if ( ZM_OPT_EMAIL && $filter->{AutoEmail} )
if ( $Config{ZM_OPT_EMAIL} && $filter->{AutoEmail} )
{
if ( !$event->{Emailed} )
{
$delete_ok = undef if ( !sendEmail( $filter, $event ) );
}
}
if ( ZM_OPT_MESSAGE && $filter->{AutoMessage} )
if ( $Config{ZM_OPT_MESSAGE} && $filter->{AutoMessage} )
{
if ( !$event->{Messaged} )
{
$delete_ok = undef if ( !sendMessage( $filter, $event ) );
}
}
if ( ZM_OPT_UPLOAD && $filter->{AutoUpload} )
if ( $Config{ZM_OPT_UPLOAD} && $filter->{AutoUpload} )
{
if ( !$event->{Uploaded} )
{
@ -618,7 +618,7 @@ sub checkFilter
my $sth = $dbh->prepare_cached( $sql ) or Fatal( "Can't prepare '$sql': ".$dbh->errstr() );
my $res = $sth->execute( $event->{Id} ) or Fatal( "Can't execute '$sql': ".$sth->errstr() );
if ( !ZM_OPT_FAST_DELETE )
if ( ! $Config{ZM_OPT_FAST_DELETE} )
{
my $sql = "delete from Frames where EventId = ?";
my $sth = $dbh->prepare_cached( $sql ) or Fatal( "Can't prepare '$sql': ".$dbh->errstr() );
@ -650,7 +650,7 @@ sub generateVideo
my $scale = $event->{DefaultScale}/100;
my $format;
my @ffmpeg_formats = split( /\s+/, ZM_FFMPEG_FORMATS );
my @ffmpeg_formats = split( /\s+/, $Config{ZM_FFMPEG_FORMATS} );
my $default_video_format;
my $default_phone_format;
foreach my $ffmpeg_format( @ffmpeg_formats )
@ -678,7 +678,7 @@ sub generateVideo
$format = $ffmpeg_formats[0];
}
my $command = ZM_PATH_BIN."/zmvideo.pl -e ".$event->{Id}." -r ".$rate." -s ".$scale." -f ".$format;
my $command = $Config{ZM_PATH_BIN}."/zmvideo.pl -e ".$event->{Id}." -r ".$rate." -s ".$scale." -f ".$format;
my $output = qx($command);
chomp( $output );
my $status = $? >> 8;
@ -713,22 +713,22 @@ sub uploadArchFile
my $filter = shift;
my $event = shift;
if ( !ZM_UPLOAD_HOST )
if ( ! $Config{ZM_UPLOAD_HOST} )
{
Error( "Cannot upload archive as no upload host defined" );
return( 0 );
}
my $archFile = $event->{MonitorName}.'-'.$event->{Id};
my $archImagePath = getEventPath( $event )."/".((ZM_UPLOAD_ARCH_ANALYSE)?'{*analyse,*capture}':'*capture').".jpg";
my $archImagePath = getEventPath( $event )."/".(( $Config{ZM_UPLOAD_ARCH_ANALYSE} )?'{*analyse,*capture}':'*capture').".jpg";
my @archImageFiles = glob($archImagePath);
my $archLocPath;
my $archError = 0;
if ( ZM_UPLOAD_ARCH_FORMAT eq "zip" )
if ( $Config{ZM_UPLOAD_ARCH_FORMAT} eq "zip" )
{
$archFile .= '.zip';
$archLocPath = ZM_UPLOAD_LOC_DIR.'/'.$archFile;
$archLocPath = $Config{ZM_UPLOAD_LOC_DIR}.'/'.$archFile;
my $zip = Archive::Zip->new();
Info( "Creating upload file '$archLocPath', ".int(@archImageFiles)." files\n" );
@ -743,7 +743,7 @@ sub uploadArchFile
$archError = 1;
last;
}
$member->desiredCompressionMethod( (ZM_UPLOAD_ARCH_COMPRESS)?&COMPRESSION_DEFLATED:&COMPRESSION_STORED );
$member->desiredCompressionMethod( $Config{ZM_UPLOAD_ARCH_COMPRESS} ? &COMPRESSION_DEFLATED : &COMPRESSION_STORED );
}
if ( !$archError )
{
@ -759,9 +759,9 @@ sub uploadArchFile
Error( "Error adding images to zip archive $archLocPath, not writing" );
}
}
elsif ( ZM_UPLOAD_ARCH_FORMAT eq "tar" )
elsif ( $Config{ZM_UPLOAD_ARCH_FORMAT} eq "tar" )
{
if ( ZM_UPLOAD_ARCH_COMPRESS )
if ( $Config{ZM_UPLOAD_ARCH_COMPRESS} )
{
$archFile .= '.tar.gz';
}
@ -769,10 +769,10 @@ sub uploadArchFile
{
$archFile .= '.tar';
}
$archLocPath = ZM_UPLOAD_LOC_DIR.'/'.$archFile;
$archLocPath = $Config{ZM_UPLOAD_LOC_DIR}.'/'.$archFile;
Info( "Creating upload file '$archLocPath', ".int(@archImageFiles)." files\n" );
if ( $archError = !Archive::Tar->create_archive( $archLocPath, ZM_UPLOAD_ARCH_COMPRESS, @archImageFiles ) )
if ( $archError = !Archive::Tar->create_archive( $archLocPath, $Config{ZM_UPLOAD_ARCH_COMPRESS}, @archImageFiles ) )
{
Error( "Tar error: ".Archive::Tar->error()."\n " );
}
@ -784,39 +784,39 @@ sub uploadArchFile
}
else
{
if ( ZM_UPLOAD_PROTOCOL eq "ftp" )
if ( $Config{ZM_UPLOAD_PROTOCOL} eq "ftp" )
{
Info( "Uploading to ".ZM_UPLOAD_HOST." using FTP\n" );
my $ftp = Net::FTP->new( ZM_UPLOAD_HOST, Timeout=>ZM_UPLOAD_TIMEOUT, Passive=>ZM_UPLOAD_FTP_PASSIVE, Debug=>ZM_UPLOAD_DEBUG );
Info( "Uploading to ".$Config{ZM_UPLOAD_HOST}." using FTP\n" );
my $ftp = Net::FTP->new( $Config{ZM_UPLOAD_HOST}, Timeout=>$Config{ZM_UPLOAD_TIMEOUT}, Passive=>$Config{ZM_UPLOAD_FTP_PASSIVE}, Debug=>$Config{ZM_UPLOAD_DEBUG} );
if ( !$ftp )
{
Error( "Can't create FTP connection: $@" );
return( 0 );
}
$ftp->login( ZM_UPLOAD_USER, ZM_UPLOAD_PASS ) or Error( "FTP - Can't login" );
$ftp->login( $Config{ZM_UPLOAD_USER}, $Config{ZM_UPLOAD_PASS} ) or Error( "FTP - Can't login" );
$ftp->binary() or Error( "FTP - Can't go binary" );
$ftp->cwd( ZM_UPLOAD_REM_DIR ) or Error( "FTP - Can't cwd" ) if ( ZM_UPLOAD_REM_DIR );
$ftp->cwd( $Config{ZM_UPLOAD_REM_DIR} ) or Error( "FTP - Can't cwd" ) if ( $Config{ZM_UPLOAD_REM_DIR} );
$ftp->put( $archLocPath ) or Error( "FTP - Can't upload '$archLocPath'" );
$ftp->quit() or Error( "FTP - Can't quit" );
}
else
{
my $host = ZM_UPLOAD_HOST;
$host .= ":".ZM_UPLOAD_PORT if ( ZM_UPLOAD_PORT );
my $host = $Config{ZM_UPLOAD_HOST};
$host .= ":".$Config{ZM_UPLOAD_PORT} if $Config{ZM_UPLOAD_PORT};
Info( "Uploading to ".$host." using SFTP\n" );
my %sftpOptions = ( host=>ZM_UPLOAD_HOST, user=>ZM_UPLOAD_USER );
$sftpOptions{password} = ZM_UPLOAD_PASS if ( ZM_UPLOAD_PASS );
$sftpOptions{port} = ZM_UPLOAD_PORT if ( ZM_UPLOAD_PORT );
$sftpOptions{timeout} = ZM_UPLOAD_TIMEOUT if ( ZM_UPLOAD_TIMEOUT );
my %sftpOptions = ( host=>$Config{ZM_UPLOAD_HOST}, user=>$Config{ZM_UPLOAD_USER} );
$sftpOptions{password} = $Config{ZM_UPLOAD_PASS} if $Config{ZM_UPLOAD_PASS};
$sftpOptions{port} = $Config{ZM_UPLOAD_PORT} if $Config{ZM_UPLOAD_PORT};
$sftpOptions{timeout} = $Config{ZM_UPLOAD_TIMEOUT} if $Config{ZM_UPLOAD_TIMEOUT};
$sftpOptions{more} = [ '-o'=>'StrictHostKeyChecking=no' ];
$Net::SFTP::Foreign::debug = -1 if ( ZM_UPLOAD_DEBUG );
my $sftp = Net::SFTP::Foreign->new( ZM_UPLOAD_HOST, %sftpOptions );
$Net::SFTP::Foreign::debug = -1 if $Config{ZM_UPLOAD_DEBUG};
my $sftp = Net::SFTP::Foreign->new( $Config{ZM_UPLOAD_HOST}, %sftpOptions );
if ( $sftp->error )
{
Error( "Can't create SFTP connection: ".$sftp->error );
return( 0 );
}
$sftp->setcwd( ZM_UPLOAD_REM_DIR ) or Error( "SFTP - Can't setcwd: ".$sftp->error ) if ( ZM_UPLOAD_REM_DIR );
$sftp->setcwd( $Config{ZM_UPLOAD_REM_DIR} ) or Error( "SFTP - Can't setcwd: ".$sftp->error ) if $Config{ZM_UPLOAD_REM_DIR};
$sftp->put( $archLocPath, $archFile ) or Error( "SFTP - Can't upload '$archLocPath': ".$sftp->error );
}
unlink( $archLocPath );
@ -908,18 +908,18 @@ sub substituteTags
$text =~ s/%EPIM%/$url?view=frame&mid=$event->{MonitorId}&eid=$event->{Id}&fid=$max_alarm_frame->{FrameId}/g;
if ( $attachments_ref && $text =~ s/%EI1%//g )
{
push( @$attachments_ref, { type=>"image/jpeg", path=>sprintf( "%s/%0".ZM_EVENT_IMAGE_DIGITS."d-capture.jpg", getEventPath( $event ), $first_alarm_frame->{FrameId} ) } );
push( @$attachments_ref, { type=>"image/jpeg", path=>sprintf( "%s/%0".$Config{ZM_EVENT_IMAGE_DIGITS}."d-capture.jpg", getEventPath( $event ), $first_alarm_frame->{FrameId} ) } );
}
if ( $attachments_ref && $text =~ s/%EIM%//g )
{
# Don't attach the same image twice
if ( !@$attachments_ref || ($first_alarm_frame->{FrameId} != $max_alarm_frame->{FrameId} ) )
{
push( @$attachments_ref, { type=>"image/jpeg", path=>sprintf( "%s/%0".ZM_EVENT_IMAGE_DIGITS."d-capture.jpg", getEventPath( $event ), $max_alarm_frame->{FrameId} ) } );
push( @$attachments_ref, { type=>"image/jpeg", path=>sprintf( "%s/%0".$Config{ZM_EVENT_IMAGE_DIGITS}."d-capture.jpg", getEventPath( $event ), $max_alarm_frame->{FrameId} ) } );
}
}
}
if ( $attachments_ref && ZM_OPT_FFMPEG )
if ( $attachments_ref && $Config{ZM_OPT_FFMPEG} )
{
if ( $text =~ s/%EV%//g )
{
@ -952,12 +952,12 @@ sub sendEmail
my $filter = shift;
my $event = shift;
if ( !ZM_FROM_EMAIL )
if ( ! $Config{ZM_FROM_EMAIL} )
{
Error( "No 'from' email address defined, not sending email" );
return( 0 );
}
if ( !ZM_EMAIL_ADDRESS )
if ( ! $Config{ZM_EMAIL_ADDRESS} )
{
Error( "No email address defined, not sending email" );
return( 0 );
@ -965,22 +965,22 @@ sub sendEmail
Info( "Creating notification email\n" );
my $subject = substituteTags( ZM_EMAIL_SUBJECT, $filter, $event );
my $subject = substituteTags( $Config{ZM_EMAIL_SUBJECT}, $filter, $event );
return( 0 ) if ( !$subject );
my @attachments;
my $body = substituteTags( ZM_EMAIL_BODY, $filter, $event, \@attachments );
my $body = substituteTags( $Config{ZM_EMAIL_BODY}, $filter, $event, \@attachments );
return( 0 ) if ( !$body );
Info( "Sending notification email '$subject'\n" );
eval
{
if ( ZM_NEW_MAIL_MODULES )
if ( $Config{ZM_NEW_MAIL_MODULES} )
{
### Create the multipart container
my $mail = MIME::Lite->new (
From => ZM_FROM_EMAIL,
To => ZM_EMAIL_ADDRESS,
From => $Config{ZM_FROM_EMAIL},
To => $Config{ZM_EMAIL_ADDRESS},
Subject => $subject,
Type => "multipart/mixed"
);
@ -1000,14 +1000,14 @@ sub sendEmail
);
}
### Send the Message
MIME::Lite->send( "smtp", ZM_EMAIL_HOST, Timeout=>60 );
MIME::Lite->send( "smtp", $Config{ZM_EMAIL_HOST}, Timeout=>60 );
$mail->send();
}
else
{
my $mail = MIME::Entity->build(
From => ZM_FROM_EMAIL,
To => ZM_EMAIL_ADDRESS,
From => $Config{ZM_FROM_EMAIL},
To => $Config{ZM_EMAIL_ADDRESS},
Subject => $subject,
Type => (($body=~/<html>/)?'text/html':'text/plain'),
Data => $body
@ -1022,7 +1022,7 @@ sub sendEmail
Encoding => "base64"
);
}
$mail->smtpsend( Host => ZM_EMAIL_HOST, MailFrom => ZM_FROM_EMAIL );
$mail->smtpsend( Host => $Config{ZM_EMAIL_HOST}, MailFrom => $Config{ZM_FROM_EMAIL} );
}
};
if ( $@ )
@ -1046,12 +1046,12 @@ sub sendMessage
my $filter = shift;
my $event = shift;
if ( !ZM_FROM_EMAIL )
if ( ! $Config{ZM_FROM_EMAIL} )
{
Error( "No 'from' email address defined, not sending message" );
return( 0 );
}
if ( !ZM_MESSAGE_ADDRESS )
if ( ! $Config{ZM_MESSAGE_ADDRESS} )
{
Error( "No message address defined, not sending message" );
return( 0 );
@ -1059,22 +1059,22 @@ sub sendMessage
Info( "Creating notification message\n" );
my $subject = substituteTags( ZM_MESSAGE_SUBJECT, $filter, $event );
my $subject = substituteTags( $Config{ZM_MESSAGE_SUBJECT}, $filter, $event );
return( 0 ) if ( !$subject );
my @attachments;
my $body = substituteTags( ZM_MESSAGE_BODY, $filter, $event, \@attachments );
my $body = substituteTags( $Config{ZM_MESSAGE_BODY}, $filter, $event, \@attachments );
return( 0 ) if ( !$body );
Info( "Sending notification message '$subject'\n" );
eval
{
if ( ZM_NEW_MAIL_MODULES )
if ( $Config{ZM_NEW_MAIL_MODULES} )
{
### Create the multipart container
my $mail = MIME::Lite->new (
From => ZM_FROM_EMAIL,
To => ZM_MESSAGE_ADDRESS,
From => $Config{ZM_FROM_EMAIL},
To => $Config{ZM_MESSAGE_ADDRESS},
Subject => $subject,
Type => "multipart/mixed"
);
@ -1094,14 +1094,14 @@ sub sendMessage
);
}
### Send the Message
MIME::Lite->send( "smtp", ZM_EMAIL_HOST, Timeout=>60 );
MIME::Lite->send( "smtp", $Config{ZM_EMAIL_HOST}, Timeout=>60 );
$mail->send();
}
else
{
my $mail = MIME::Entity->build(
From => ZM_FROM_EMAIL,
To => ZM_MESSAGE_ADDRESS,
From => $Config{ZM_FROM_EMAIL},
To => $Config{ZM_MESSAGE_ADDRESS},
Subject => $subject,
Type => (($body=~/<html>/)?'text/html':'text/plain'),
Data => $body
@ -1116,7 +1116,7 @@ sub sendMessage
Encoding => "base64"
);
}
$mail->smtpsend( Host => ZM_EMAIL_HOST, MailFrom => ZM_FROM_EMAIL );
$mail->smtpsend( Host => $Config{ZM_EMAIL_HOST}, MailFrom => $Config{ZM_FROM_EMAIL} );
}
};
if ( $@ )

View File

@ -84,7 +84,7 @@ if ( !$command || $command !~ /^(?:start|stop|restart|status|logrot)$/ )
}
# Move to the right place
chdir( ZM_PATH_WEB ) or Fatal( "Can't chdir to '".ZM_PATH_WEB."': $!" );
chdir( $Config{ZM_PATH_WEB} ) or Fatal( "Can't chdir to '".$Config{ZM_PATH_WEB}."': $!" );
my $dbg_id = "";
@ -146,9 +146,9 @@ if ( $command =~ /^(?:start|restart)$/ )
if ( $status eq "stopped" )
{
if ( ZM_DYN_DB_VERSION && ZM_DYN_DB_VERSION ne ZM_VERSION )
if ( $Config{ZM_DYN_DB_VERSION} and ( $Config{ZM_DYN_DB_VERSION} ne $Config{ZM_VERSION} ) )
{
Fatal( "Version mismatch, system is version ".ZM_VERSION.", database is ".ZM_DYN_DB_VERSION.", please run zmupdate.pl to update." );
Fatal( "Version mismatch, system is version ".ZM_VERSION.", database is ".$Config{ZM_DYN_DB_VERSION}.", please run zmupdate.pl to update." );
exit( -1 );
}
@ -158,11 +158,11 @@ if ( $command =~ /^(?:start|restart)$/ )
Debug( "Recreating temporary directory '@ZM_TMPDIR@'" );
mkdir( "@ZM_TMPDIR@", 0700 ) or Fatal( "Can't create missing temporary directory '@ZM_TMPDIR@': $!" );
my ( $runName ) = getpwuid( $> );
if ( $runName ne ZM_WEB_USER )
if ( $runName ne $Config{ZM_WEB_USER} )
{
# Not running as web user, so should be root in whch case chown the temporary directory
my ( $webName, $webPass, $webUid, $webGid ) = getpwnam( ZM_WEB_USER ) or Fatal( "Can't get user details for web user '".ZM_WEB_USER."': $!" );
chown( $webUid, $webGid, "@ZM_TMPDIR@" ) or Fatal( "Can't change ownership of temporary directory '@ZM_TMPDIR@' to '".ZM_WEB_USER.":".ZM_WEB_GROUP."': $!" );
my ( $webName, $webPass, $webUid, $webGid ) = getpwnam( $Config{ZM_WEB_USER} ) or Fatal( "Can't get user details for web user '".$Config{ZM_WEB_USER}."': $!" );
chown( $webUid, $webGid, "@ZM_TMPDIR@" ) or Fatal( "Can't change ownership of temporary directory '@ZM_TMPDIR@' to '".$Config{ZM_WEB_USER}.":".$Config{ZM_WEB_GROUP}."': $!" );
}
}
zmMemTidy();
@ -186,13 +186,13 @@ if ( $command =~ /^(?:start|restart)$/ )
}
if ( $monitor->{Function} ne 'Monitor' )
{
if ( ZM_OPT_FRAME_SERVER )
if ( $Config{ZM_OPT_FRAME_SERVER} )
{
runCommand( "zmdc.pl start zmf -m $monitor->{Id}" );
}
runCommand( "zmdc.pl start zma -m $monitor->{Id}" );
}
if ( ZM_OPT_CONTROL )
if ( $Config{ZM_OPT_CONTROL} )
{
if ( $monitor->{Function} eq 'Modect' || $monitor->{Function} eq 'Mocord' )
{
@ -208,20 +208,20 @@ if ( $command =~ /^(?:start|restart)$/ )
# This is now started unconditionally
runCommand( "zmdc.pl start zmfilter.pl" );
if ( ZM_RUN_AUDIT )
if ( $Config{ZM_RUN_AUDIT} )
{
runCommand( "zmdc.pl start zmaudit.pl -c" );
}
if ( ZM_OPT_TRIGGERS )
if ( $Config{ZM_OPT_TRIGGERS} )
{
runCommand( "zmdc.pl start zmtrigger.pl" );
}
if ( ZM_OPT_X10 )
if ( $Config{ZM_OPT_X10} )
{
runCommand( "zmdc.pl start zmx10.pl -c start" );
}
runCommand( "zmdc.pl start zmwatch.pl" );
if ( ZM_CHECK_FOR_UPDATES )
if ( $Config{ZM_CHECK_FOR_UPDATES} )
{
runCommand( "zmdc.pl start zmupdate.pl -c" );
}
@ -245,3 +245,5 @@ if ( $command eq "logrot" )
}
exit( $retval );
__END__

View File

@ -54,7 +54,7 @@ use DBI;
use Getopt::Long;
use Data::Dumper;
use constant EVENT_PATH => (ZM_DIR_EVENTS=~m|/|)?ZM_DIR_EVENTS:(ZM_PATH_WEB.'/'.ZM_DIR_EVENTS);
use constant EVENT_PATH => ($Config{ZM_DIR_EVENTS}=~m|/|)?$Config{ZM_DIR_EVENTS}:($Config{ZM_PATH_WEB}.'/'.$Config{ZM_DIR_EVENTS});
$| = 1;
@ -62,7 +62,7 @@ $ENV{PATH} = '/bin:/usr/bin:/usr/local/bin';
$ENV{SHELL} = '/bin/sh' if exists $ENV{SHELL};
delete @ENV{qw(IFS CDPATH ENV BASH_ENV)};
my $web_uid = (getpwnam( ZM_WEB_USER ))[2];
my $web_uid = (getpwnam( $Config{ZM_WEB_USER} ))[2];
my $use_log = (($> == 0) || ($> == $web_uid));
logInit( toFile=>$use_log?DEBUG:NOLOG );
@ -75,8 +75,8 @@ my $rename = 0;
my $zoneFix = 0;
my $migrateEvents = 0;
my $version = '';
my $dbUser = ZM_DB_USER;
my $dbPass = ZM_DB_PASS;
my $dbUser = $Config{ZM_DB_USER};
my $dbPass = $Config{ZM_DB_PASS};
my $updateDir = '';
sub Usage
{
@ -99,14 +99,14 @@ if ( !GetOptions( 'check'=>\$check, 'freshen'=>\$freshen, 'rename'=>\$rename, 'z
}
my $dbh = zmDbConnect();
*ZoneMinder::Database::ZM_DB_USER = sub { $dbUser } if ZoneMinder::Database::ZM_DB_USER ne $dbUser;
*ZoneMinder::Database::ZM_DB_PASS = sub { $dbPass } if ZoneMinder::Database::ZM_DB_PASS ne $dbPass;
$Config{ZM_DB_USER} = $dbUser;
$Config{ZM_DB_PASS} = $dbPass;
if ( ! ($check || $freshen || $rename || $zoneFix || $migrateEvents || $version) )
{
if ( ZM_DYN_DB_VERSION )
if ( $Config{ZM_DYN_DB_VERSION} )
{
$version = ZM_DYN_DB_VERSION;
$version = $Config{ZM_DYN_DB_VERSION};
}
else
{
@ -121,17 +121,17 @@ if ( ($check + $freshen + $rename + $zoneFix + $migrateEvents + ($version?1:0))
Usage();
}
if ( $check && ZM_CHECK_FOR_UPDATES )
if ( $check && $Config{ZM_CHECK_FOR_UPDATES} )
{
print( "Update agent starting at ".strftime( '%y/%m/%d %H:%M:%S', localtime() )."\n" );
my $currVersion = ZM_DYN_CURR_VERSION;
my $lastVersion = ZM_DYN_LAST_VERSION;
my $lastCheck = ZM_DYN_LAST_CHECK;
my $currVersion = $Config{ZM_DYN_CURR_VERSION};
my $lastVersion = $Config{ZM_DYN_LAST_VERSION};
my $lastCheck = $Config{ZM_DYN_LAST_CHECK};
if ( !$currVersion )
{
$currVersion = ZM_VERSION;
$currVersion = $Config{ZM_VERSION};
my $sql = "update Config set Value = ? where Name = 'ZM_DYN_CURR_VERSION'";
my $sth = $dbh->prepare_cached( $sql ) or die( "Can't prepare '$sql': ".$dbh->errstr() );
@ -148,14 +148,8 @@ if ( $check && ZM_CHECK_FOR_UPDATES )
use LWP::UserAgent;
my $ua = LWP::UserAgent->new;
$ua->agent( "ZoneMinder Update Agent/".ZM_VERSION );
if ( eval('defined(ZM_UPDATE_CHECK_PROXY)') )
{
no strict 'subs';
if ( ZM_UPDATE_CHECK_PROXY )
{
$ua->proxy( "http", ZM_UPDATE_CHECK_PROXY );
}
use strict 'subs';
if ( $Config{ZM_UPDATE_CHECK_PROXY} ) {
$ua->proxy( "http", $Config{ZM_UPDATE_CHECK_PROXY} );
}
my $req = HTTP::Request->new( GET=>'http://zoneminder.github.io/ZoneMinder/version.txt' );
my $res = $ua->request($req);
@ -247,12 +241,12 @@ if ( $zoneFix )
}
if ( $migrateEvents )
{
my $webUid = (getpwnam( ZM_WEB_USER ))[2];
my $webGid = (getgrnam( ZM_WEB_USER ))[2];
my $webUid = (getpwnam( $Config{ZM_WEB_USER} ))[2];
my $webGid = (getgrnam( $Config{ZM_WEB_USER} ))[2];
if ( !(($> == 0) || ($> == $webUid)) )
{
print( "Error, migrating events can only be done as user root or ".ZM_WEB_USER.".\n" );
print( "Error, migrating events can only be done as user root or ".$Config{ZM_WEB_USER}.".\n" );
exit( -1 );
}
@ -276,7 +270,7 @@ if ( $migrateEvents )
{
print( "Converting all events to deep storage.\n" );
chdir( ZM_PATH_WEB );
chdir( $Config{ZM_PATH_WEB} );
my $sql = "select *, unix_timestamp(StartTime) as UnixStartTime from Events";
my $sth = $dbh->prepare_cached( $sql ) or Fatal( "Can't prepare '$sql': ".$dbh->errstr() );
my $res = $sth->execute();
@ -287,7 +281,7 @@ if ( $migrateEvents )
while( my $event = $sth->fetchrow_hashref() )
{
my $oldEventPath = ZM_DIR_EVENTS.'/'.$event->{MonitorId}.'/'.$event->{Id};
my $oldEventPath = $Config{ZM_DIR_EVENTS}.'/'.$event->{MonitorId}.'/'.$event->{Id};
if ( !-d $oldEventPath )
{
@ -296,11 +290,11 @@ if ( $migrateEvents )
}
print( "Converting event ".$event->{Id}."\n" );
my $newDatePath = ZM_DIR_EVENTS.'/'.$event->{MonitorId}.'/'.strftime( "%y/%m/%d", localtime($event->{UnixStartTime}) );
my $newDatePath = $Config{ZM_DIR_EVENTS}.'/'.$event->{MonitorId}.'/'.strftime( "%y/%m/%d", localtime($event->{UnixStartTime}) );
my $newTimePath = strftime( "%H/%M/%S", localtime($event->{UnixStartTime}) );
my $newEventPath = $newDatePath.'/'.$newTimePath;
( my $truncEventPath = $newEventPath ) =~ s|/\d+$||;
makePath( $truncEventPath, ZM_PATH_WEB );
makePath( $truncEventPath, $Config{ZM_PATH_WEB} );
my $idLink = $newDatePath.'/.'.$event->{Id};
symlink( $newTimePath, $idLink ) or die( "Can't symlink $newTimePath -> $idLink: $!" );
rename( $oldEventPath, $newEventPath ) or die( "Can't move $oldEventPath -> $newEventPath: $!" );
@ -366,9 +360,9 @@ if ( $version )
print( "\nInitiating database upgrade to version ".ZM_VERSION." from version $version\n" );
if ( $interactive )
{
if ( ZM_DYN_DB_VERSION && ZM_DYN_DB_VERSION ne $version )
if ( $Config{ZM_DYN_DB_VERSION} && $Config{ZM_DYN_DB_VERSION} ne $version )
{
print( "\nWARNING - You have specified an upgrade from version $version but the database version found is ".ZM_DYN_DB_VERSION.". Is this correct?\nPress enter to continue or ctrl-C to abort : " );
print( "\nWARNING - You have specified an upgrade from version $version but the database version found is ".$Config{ZM_DYN_DB_VERSION}.". Is this correct?\nPress enter to continue or ctrl-C to abort : " );
my $response = <STDIN>;
}
@ -387,7 +381,7 @@ if ( $version )
if ( $response =~ /^[yY]$/ )
{
my ( $host, $port ) = ( ZM_DB_HOST =~ /^([^:]+)(?::(.+))?$/ );
my ( $host, $port ) = ( $Config{ZM_DB_HOST} =~ /^([^:]+)(?::(.+))?$/ );
my $command = "mysqldump -h".$host;
$command .= " -P".$port if defined($port);
if ( $dbUser )
@ -398,8 +392,8 @@ if ( $version )
$command .= " -p".$dbPass;
}
}
my $backup = "@ZM_TMPDIR@/".ZM_DB_NAME."-".$version.".dump";
$command .= " --add-drop-table --databases ".ZM_DB_NAME." > ".$backup;
my $backup = "@ZM_TMPDIR@/".$Config{ZM_DB_NAME}."-".$version.".dump";
$command .= " --add-drop-table --databases ".$Config{ZM_DB_NAME}." > ".$backup;
print( "Creating backup to $backup. This may take several minutes.\n" );
print( "Executing '$command'\n" ) if ( logDebugging() );
my $output = qx($command);
@ -428,7 +422,7 @@ if ( $version )
my $dbh = shift;
my $version = shift;
my ( $host, $port ) = ( ZM_DB_HOST =~ /^([^:]+)(?::(.+))?$/ );
my ( $host, $port ) = ( $Config{ZM_DB_HOST} =~ /^([^:]+)(?::(.+))?$/ );
my $command = "mysql -h".$host;
$command .= " -P".$port if defined($port);
if ( $dbUser )
@ -439,14 +433,14 @@ if ( $version )
$command .= " -p".$dbPass;
}
}
$command .= " ".ZM_DB_NAME." < ";
$command .= " ".$Config{ZM_DB_NAME}." < ";
if ( $updateDir )
{
$command .= $updateDir;
}
else
{
$command .= ZM_PATH_DATA."/db";
$command .= $Config{ZM_PATH_DATA}."/db";
}
$command .= "/zm_update-".$version.".sql";
@ -727,7 +721,7 @@ if ( $version )
my ( $sql, $sth, $res );
if ( defined(&ZM_EMAIL_TEXT) && &ZM_EMAIL_TEXT )
{
my ( $email_subject, $email_body ) = ZM_EMAIL_TEXT =~ /subject\s*=\s*"([^\n]*)".*body\s*=\s*"(.*)"?$/ms;
my ( $email_subject, $email_body ) = $Config{ZM_EMAIL_TEXT} =~ /subject\s*=\s*"([^\n]*)".*body\s*=\s*"(.*)"?$/ms;
$sql = "replace into Config set Id = 0, Name = 'ZM_EMAIL_SUBJECT', Value = '".$email_subject."', Type = 'string', DefaultValue = 'ZoneMinder: Alarm - %MN%-%EI% (%ESM% - %ESA% %EFA%)', Hint = 'string', Pattern = '(?-xism:^(.+)\$)', Format = ' \$1 ', Prompt = 'The subject of the email used to send matching event details', Help = 'This option is used to define the subject of the email that is sent for any events that match the appropriate filters.', Category = 'mail', Readonly = '0', Requires = 'ZM_OPT_EMAIL=1'";
$sth = $dbh->prepare_cached( $sql ) or die( "Can't prepare '$sql': ".$dbh->errstr() );
$res = $sth->execute() or die( "Can't execute: ".$sth->errstr() );
@ -737,7 +731,7 @@ if ( $version )
}
if ( defined(&ZM_MESSAGE_TEXT) && &ZM_MESSAGE_TEXT )
{
my ( $message_subject, $message_body ) = ZM_MESSAGE_TEXT =~ /subject\s*=\s*"([^\n]*)".*body\s*=\s*"(.*)"?$/ms;
my ( $message_subject, $message_body ) = $Config{ZM_MESSAGE_TEXT} =~ /subject\s*=\s*"([^\n]*)".*body\s*=\s*"(.*)"?$/ms;
$sql = "replace into Config set Id = 0, Name = 'ZM_MESSAGE_SUBJECT', Value = '".$message_subject."', Type = 'string', DefaultValue = 'ZoneMinder: Alarm - %MN%-%EI%', Hint = 'string', Pattern = '(?-xism:^(.+)\$)', Format = ' \$1 ', Prompt = 'The subject of the message used to send matching event details', Help = 'This option is used to define the subject of the message that is sent for any events that match the appropriate filters.', Category = 'mail', Readonly = '0', Requires = 'ZM_OPT_MESSAGE=1'";
$sth = $dbh->prepare_cached( $sql ) or die( "Can't prepare '$sql': ".$dbh->errstr() );
$res = $sth->execute() or die( "Can't execute: ".$sth->errstr() );
@ -871,7 +865,7 @@ if ( $version )
my $sql = "update Config set Value = ? where Name = 'ZM_JPEG_STREAM_QUALITY'";
my $sth = $dbh->prepare_cached( $sql ) or die( "Can't prepare '$sql': ".$dbh->errstr() );
my $res = $sth->execute( ZM_JPEG_IMAGE_QUALITY ) or die( "Can't execute: ".$sth->errstr() );
my $res = $sth->execute( $Config{ZM_JPEG_IMAGE_QUALITY} ) or die( "Can't execute: ".$sth->errstr() );
}
$cascade = !undef;
}
@ -1007,7 +1001,7 @@ if ( $version )
if ( $version ge '1.26.0' ) {
my @files;
$updateDir = ZM_PATH_DATA."/db" if ! $updateDir;
$updateDir = $Config{ZM_PATH_DATA}."/db" if ! $updateDir;
opendir( my $dh, $updateDir ) || die "Can't open updateDir $!";
@files = sort grep { (!/^\./) && /^zm_update\-[\d\.]+\.sql$/ && -f "$updateDir/$_" } readdir($dh);
closedir $dh;

View File

@ -56,7 +56,7 @@ my $fps = '';
my $size = '';
my $overwrite = 0;
my @formats = split( /\s+/, ZM_FFMPEG_FORMATS );
my @formats = split( /\s+/, $Config{ZM_FFMPEG_FORMATS} );
for ( my $i = 0; $i < @formats; $i++ )
{
if ( $i =~ /^(.+)\*$/ )
@ -92,7 +92,7 @@ if ( !$event_id || $event_id < 0 )
Usage();
}
if ( !ZM_OPT_FFMPEG )
if ( ! $Config{ZM_OPT_FFMPEG} )
{
print( STDERR "Mpeg encoding is not currently enabled\n" );
exit(-1);
@ -221,7 +221,7 @@ if ( $overwrite || !-s $video_file )
$video_size = $size;
}
my $command = ZM_PATH_FFMPEG." -y -r $frame_rate ".ZM_FFMPEG_INPUT_OPTIONS." -i %0".ZM_EVENT_IMAGE_DIGITS."d-capture.jpg -s $video_size ".ZM_FFMPEG_OUTPUT_OPTIONS." '$video_file' > ffmpeg.log 2>&1";
my $command = $Config{ZM_PATH_FFMPEG}." -y -r $frame_rate ".$Config{ZM_FFMPEG_INPUT_OPTIONS}." -i %0".$Config{ZM_EVENT_IMAGE_DIGITS}."d-capture.jpg -s $video_size ".$Config{ZM_FFMPEG_OUTPUT_OPTIONS}." '$video_file' > ffmpeg.log 2>&1";
Debug( $command."\n" );
my $output = qx($command);

View File

@ -90,7 +90,7 @@ while( 1 )
next if ( !defined($image_time) ); # Can't read from shared data
next if ( !$image_time ); # We can't get the last capture time so can't be sure it's died.
my $max_image_delay = ($monitor->{MaxFPS}&&($monitor->{MaxFPS}>0)&&($monitor->{MaxFPS}<1))?(3/$monitor->{MaxFPS}):ZM_WATCH_MAX_DELAY;
my $max_image_delay = ($monitor->{MaxFPS}&&($monitor->{MaxFPS}>0)&&($monitor->{MaxFPS}<1))?(3/$monitor->{MaxFPS}):$Config{ZM_WATCH_MAX_DELAY};
my $image_delay = $now-$image_time;
Debug( "Monitor $monitor->{Id} last captured $image_delay seconds ago, max is $max_image_delay\n" );
if ( $image_delay > $max_image_delay )
@ -127,7 +127,7 @@ while( 1 )
next if ( !defined($image_time) ); # Can't read from shared data
next if ( !$image_time ); # We can't get the last capture time so can't be sure it's died.
my $max_image_delay = ($monitor->{MaxFPS}&&($monitor->{MaxFPS}>0)&&($monitor->{MaxFPS}<1))?(3/$monitor->{MaxFPS}):ZM_WATCH_MAX_DELAY;
my $max_image_delay = ($monitor->{MaxFPS}&&($monitor->{MaxFPS}>0)&&($monitor->{MaxFPS}<1))?(3/$monitor->{MaxFPS}):$Config{ZM_WATCH_MAX_DELAY};
my $image_delay = $now-$image_time;
Debug( "Monitor $monitor->{Id} last analysed $image_delay seconds ago, max is $max_image_delay\n" );
if ( $image_delay > $max_image_delay )
@ -142,7 +142,7 @@ while( 1 )
# Prevent open handles building up if we have connect to shared memory
zmMemInvalidate( $monitor );
}
sleep( ZM_WATCH_CHECK_INTERVAL );
sleep( $Config{ZM_WATCH_CHECK_INTERVAL} );
}
Info( "Watchdog exiting\n" );
exit();

View File

@ -30,196 +30,195 @@
#define ZM_CPU_EXTENSIONS 26
#define ZM_FAST_IMAGE_BLENDS 27
#define ZM_OPT_ADAPTIVE_SKIP 28
#define ZM_BLEND_ALARMED_IMAGES 29
#define ZM_MAX_SUSPEND_TIME 30
#define ZM_OPT_REMOTE_CAMERAS 31
#define ZM_NETCAM_REGEXPS 32
#define ZM_HTTP_VERSION 33
#define ZM_HTTP_UA 34
#define ZM_HTTP_TIMEOUT 35
#define ZM_MIN_RTP_PORT 36
#define ZM_MAX_RTP_PORT 37
#define ZM_OPT_FFMPEG 38
#define ZM_PATH_FFMPEG 39
#define ZM_FFMPEG_INPUT_OPTIONS 40
#define ZM_FFMPEG_OUTPUT_OPTIONS 41
#define ZM_FFMPEG_FORMATS 42
#define ZM_LOG_LEVEL_SYSLOG 43
#define ZM_LOG_LEVEL_FILE 44
#define ZM_LOG_LEVEL_WEBLOG 45
#define ZM_LOG_LEVEL_DATABASE 46
#define ZM_LOG_DATABASE_LIMIT 47
#define ZM_LOG_DEBUG 48
#define ZM_LOG_DEBUG_TARGET 49
#define ZM_LOG_DEBUG_LEVEL 50
#define ZM_LOG_DEBUG_FILE 51
#define ZM_LOG_CHECK_PERIOD 52
#define ZM_LOG_ALERT_WAR_COUNT 53
#define ZM_LOG_ALERT_ERR_COUNT 54
#define ZM_LOG_ALERT_FAT_COUNT 55
#define ZM_LOG_ALARM_WAR_COUNT 56
#define ZM_LOG_ALARM_ERR_COUNT 57
#define ZM_LOG_ALARM_FAT_COUNT 58
#define ZM_RECORD_EVENT_STATS 59
#define ZM_RECORD_DIAG_IMAGES 60
#define ZM_DUMP_CORES 61
#define ZM_PATH_MAP 62
#define ZM_PATH_SOCKS 63
#define ZM_PATH_LOGS 64
#define ZM_PATH_SWAP 65
#define ZM_WEB_TITLE_PREFIX 66
#define ZM_WEB_RESIZE_CONSOLE 67
#define ZM_WEB_POPUP_ON_ALARM 68
#define ZM_OPT_X10 69
#define ZM_X10_DEVICE 70
#define ZM_X10_HOUSE_CODE 71
#define ZM_X10_DB_RELOAD_INTERVAL 72
#define ZM_WEB_SOUND_ON_ALARM 73
#define ZM_WEB_ALARM_SOUND 74
#define ZM_WEB_COMPACT_MONTAGE 75
#define ZM_OPT_FAST_DELETE 76
#define ZM_STRICT_VIDEO_CONFIG 77
#define ZM_SIGNAL_CHECK_POINTS 78
#define ZM_V4L_MULTI_BUFFER 79
#define ZM_CAPTURES_PER_FRAME 80
#define ZM_FILTER_RELOAD_DELAY 81
#define ZM_FILTER_EXECUTE_INTERVAL 82
#define ZM_OPT_UPLOAD 83
#define ZM_UPLOAD_ARCH_FORMAT 84
#define ZM_UPLOAD_ARCH_COMPRESS 85
#define ZM_UPLOAD_ARCH_ANALYSE 86
#define ZM_UPLOAD_PROTOCOL 87
#define ZM_UPLOAD_FTP_HOST 88
#define ZM_UPLOAD_HOST 89
#define ZM_UPLOAD_PORT 90
#define ZM_UPLOAD_FTP_USER 91
#define ZM_UPLOAD_USER 92
#define ZM_UPLOAD_FTP_PASS 93
#define ZM_UPLOAD_PASS 94
#define ZM_UPLOAD_FTP_LOC_DIR 95
#define ZM_UPLOAD_LOC_DIR 96
#define ZM_UPLOAD_FTP_REM_DIR 97
#define ZM_UPLOAD_REM_DIR 98
#define ZM_UPLOAD_FTP_TIMEOUT 99
#define ZM_UPLOAD_TIMEOUT 100
#define ZM_UPLOAD_FTP_PASSIVE 101
#define ZM_UPLOAD_FTP_DEBUG 102
#define ZM_UPLOAD_DEBUG 103
#define ZM_OPT_EMAIL 104
#define ZM_EMAIL_ADDRESS 105
#define ZM_EMAIL_TEXT 106
#define ZM_EMAIL_SUBJECT 107
#define ZM_EMAIL_BODY 108
#define ZM_OPT_MESSAGE 109
#define ZM_MESSAGE_ADDRESS 110
#define ZM_MESSAGE_TEXT 111
#define ZM_MESSAGE_SUBJECT 112
#define ZM_MESSAGE_BODY 113
#define ZM_NEW_MAIL_MODULES 114
#define ZM_EMAIL_HOST 115
#define ZM_FROM_EMAIL 116
#define ZM_URL 117
#define ZM_MAX_RESTART_DELAY 118
#define ZM_WATCH_CHECK_INTERVAL 119
#define ZM_WATCH_MAX_DELAY 120
#define ZM_RUN_AUDIT 121
#define ZM_AUDIT_CHECK_INTERVAL 122
#define ZM_FORCED_ALARM_SCORE 123
#define ZM_BULK_FRAME_INTERVAL 124
#define ZM_EVENT_CLOSE_MODE 125
#define ZM_FORCE_CLOSE_EVENTS 126
#define ZM_CREATE_ANALYSIS_IMAGES 127
#define ZM_WEIGHTED_ALARM_CENTRES 128
#define ZM_EVENT_IMAGE_DIGITS 129
#define ZM_DEFAULT_ASPECT_RATIO 130
#define ZM_USER_SELF_EDIT 131
#define ZM_OPT_FRAME_SERVER 132
#define ZM_FRAME_SOCKET_SIZE 133
#define ZM_OPT_CONTROL 134
#define ZM_OPT_TRIGGERS 135
#define ZM_CHECK_FOR_UPDATES 136
#define ZM_UPDATE_CHECK_PROXY 137
#define ZM_SHM_KEY 138
#define ZM_WEB_REFRESH_METHOD 139
#define ZM_WEB_EVENT_SORT_FIELD 140
#define ZM_WEB_EVENT_SORT_ORDER 141
#define ZM_WEB_EVENTS_PER_PAGE 142
#define ZM_WEB_LIST_THUMBS 143
#define ZM_WEB_LIST_THUMB_WIDTH 144
#define ZM_WEB_LIST_THUMB_HEIGHT 145
#define ZM_WEB_USE_OBJECT_TAGS 146
#define ZM_WEB_H_REFRESH_MAIN 147
#define ZM_WEB_H_REFRESH_CYCLE 148
#define ZM_WEB_H_REFRESH_IMAGE 149
#define ZM_WEB_H_REFRESH_STATUS 150
#define ZM_WEB_H_REFRESH_EVENTS 151
#define ZM_WEB_H_CAN_STREAM 152
#define ZM_WEB_H_STREAM_METHOD 153
#define ZM_WEB_H_DEFAULT_SCALE 154
#define ZM_WEB_H_DEFAULT_RATE 155
#define ZM_WEB_H_VIDEO_BITRATE 156
#define ZM_WEB_H_VIDEO_MAXFPS 157
#define ZM_WEB_H_SCALE_THUMBS 158
#define ZM_WEB_H_EVENTS_VIEW 159
#define ZM_WEB_H_SHOW_PROGRESS 160
#define ZM_WEB_H_AJAX_TIMEOUT 161
#define ZM_WEB_M_REFRESH_MAIN 162
#define ZM_WEB_M_REFRESH_CYCLE 163
#define ZM_WEB_M_REFRESH_IMAGE 164
#define ZM_WEB_M_REFRESH_STATUS 165
#define ZM_WEB_M_REFRESH_EVENTS 166
#define ZM_WEB_M_CAN_STREAM 167
#define ZM_WEB_M_STREAM_METHOD 168
#define ZM_WEB_M_DEFAULT_SCALE 169
#define ZM_WEB_M_DEFAULT_RATE 170
#define ZM_WEB_M_VIDEO_BITRATE 171
#define ZM_WEB_M_VIDEO_MAXFPS 172
#define ZM_WEB_M_SCALE_THUMBS 173
#define ZM_WEB_M_EVENTS_VIEW 174
#define ZM_WEB_M_SHOW_PROGRESS 175
#define ZM_WEB_M_AJAX_TIMEOUT 176
#define ZM_WEB_L_REFRESH_MAIN 177
#define ZM_WEB_L_REFRESH_CYCLE 178
#define ZM_WEB_L_REFRESH_IMAGE 179
#define ZM_WEB_L_REFRESH_STATUS 180
#define ZM_WEB_L_REFRESH_EVENTS 181
#define ZM_WEB_L_CAN_STREAM 182
#define ZM_WEB_L_STREAM_METHOD 183
#define ZM_WEB_L_DEFAULT_SCALE 184
#define ZM_WEB_L_DEFAULT_RATE 185
#define ZM_WEB_L_VIDEO_BITRATE 186
#define ZM_WEB_L_VIDEO_MAXFPS 187
#define ZM_WEB_L_SCALE_THUMBS 188
#define ZM_WEB_L_EVENTS_VIEW 189
#define ZM_WEB_L_SHOW_PROGRESS 190
#define ZM_WEB_L_AJAX_TIMEOUT 191
#define ZM_WEB_P_CAN_STREAM 192
#define ZM_WEB_P_STREAM_METHOD 193
#define ZM_WEB_P_DEFAULT_SCALE 194
#define ZM_WEB_P_DEFAULT_RATE 195
#define ZM_WEB_P_VIDEO_BITRATE 196
#define ZM_WEB_P_VIDEO_MAXFPS 197
#define ZM_WEB_P_SCALE_THUMBS 198
#define ZM_WEB_P_AJAX_TIMEOUT 199
#define ZM_DYN_LAST_VERSION 200
#define ZM_DYN_CURR_VERSION 201
#define ZM_DYN_DB_VERSION 202
#define ZM_DYN_LAST_CHECK 203
#define ZM_DYN_NEXT_REMINDER 204
#define ZM_DYN_DONATE_REMINDER_TIME 205
#define ZM_DYN_SHOW_DONATE_REMINDER 206
#define ZM_EYEZM_DEBUG 207
#define ZM_EYEZM_LOG_TO_FILE 208
#define ZM_EYEZM_LOG_FILE 209
#define ZM_EYEZM_EVENT_VCODEC 210
#define ZM_EYEZM_FEED_VCODEC 211
#define ZM_EYEZM_H264_DEFAULT_BR 212
#define ZM_EYEZM_H264_DEFAULT_EVBR 213
#define ZM_EYEZM_H264_TIMEOUT 214
#define ZM_EYEZM_SEG_DURATION 215
#define ZM_MAX_SUSPEND_TIME 29
#define ZM_OPT_REMOTE_CAMERAS 30
#define ZM_NETCAM_REGEXPS 31
#define ZM_HTTP_VERSION 32
#define ZM_HTTP_UA 33
#define ZM_HTTP_TIMEOUT 34
#define ZM_MIN_RTP_PORT 35
#define ZM_MAX_RTP_PORT 36
#define ZM_OPT_FFMPEG 37
#define ZM_PATH_FFMPEG 38
#define ZM_FFMPEG_INPUT_OPTIONS 39
#define ZM_FFMPEG_OUTPUT_OPTIONS 40
#define ZM_FFMPEG_FORMATS 41
#define ZM_LOG_LEVEL_SYSLOG 42
#define ZM_LOG_LEVEL_FILE 43
#define ZM_LOG_LEVEL_WEBLOG 44
#define ZM_LOG_LEVEL_DATABASE 45
#define ZM_LOG_DATABASE_LIMIT 46
#define ZM_LOG_DEBUG 47
#define ZM_LOG_DEBUG_TARGET 48
#define ZM_LOG_DEBUG_LEVEL 49
#define ZM_LOG_DEBUG_FILE 50
#define ZM_LOG_CHECK_PERIOD 51
#define ZM_LOG_ALERT_WAR_COUNT 52
#define ZM_LOG_ALERT_ERR_COUNT 53
#define ZM_LOG_ALERT_FAT_COUNT 54
#define ZM_LOG_ALARM_WAR_COUNT 55
#define ZM_LOG_ALARM_ERR_COUNT 56
#define ZM_LOG_ALARM_FAT_COUNT 57
#define ZM_RECORD_EVENT_STATS 58
#define ZM_RECORD_DIAG_IMAGES 59
#define ZM_DUMP_CORES 60
#define ZM_PATH_MAP 61
#define ZM_PATH_SOCKS 62
#define ZM_PATH_LOGS 63
#define ZM_PATH_SWAP 64
#define ZM_WEB_TITLE_PREFIX 65
#define ZM_WEB_RESIZE_CONSOLE 66
#define ZM_WEB_POPUP_ON_ALARM 67
#define ZM_OPT_X10 68
#define ZM_X10_DEVICE 69
#define ZM_X10_HOUSE_CODE 70
#define ZM_X10_DB_RELOAD_INTERVAL 71
#define ZM_WEB_SOUND_ON_ALARM 72
#define ZM_WEB_ALARM_SOUND 73
#define ZM_WEB_COMPACT_MONTAGE 74
#define ZM_OPT_FAST_DELETE 75
#define ZM_STRICT_VIDEO_CONFIG 76
#define ZM_SIGNAL_CHECK_POINTS 77
#define ZM_V4L_MULTI_BUFFER 78
#define ZM_CAPTURES_PER_FRAME 79
#define ZM_FILTER_RELOAD_DELAY 80
#define ZM_FILTER_EXECUTE_INTERVAL 81
#define ZM_OPT_UPLOAD 82
#define ZM_UPLOAD_ARCH_FORMAT 83
#define ZM_UPLOAD_ARCH_COMPRESS 84
#define ZM_UPLOAD_ARCH_ANALYSE 85
#define ZM_UPLOAD_PROTOCOL 86
#define ZM_UPLOAD_FTP_HOST 87
#define ZM_UPLOAD_HOST 88
#define ZM_UPLOAD_PORT 89
#define ZM_UPLOAD_FTP_USER 90
#define ZM_UPLOAD_USER 91
#define ZM_UPLOAD_FTP_PASS 92
#define ZM_UPLOAD_PASS 93
#define ZM_UPLOAD_FTP_LOC_DIR 94
#define ZM_UPLOAD_LOC_DIR 95
#define ZM_UPLOAD_FTP_REM_DIR 96
#define ZM_UPLOAD_REM_DIR 97
#define ZM_UPLOAD_FTP_TIMEOUT 98
#define ZM_UPLOAD_TIMEOUT 99
#define ZM_UPLOAD_FTP_PASSIVE 100
#define ZM_UPLOAD_FTP_DEBUG 101
#define ZM_UPLOAD_DEBUG 102
#define ZM_OPT_EMAIL 103
#define ZM_EMAIL_ADDRESS 104
#define ZM_EMAIL_TEXT 105
#define ZM_EMAIL_SUBJECT 106
#define ZM_EMAIL_BODY 107
#define ZM_OPT_MESSAGE 108
#define ZM_MESSAGE_ADDRESS 109
#define ZM_MESSAGE_TEXT 110
#define ZM_MESSAGE_SUBJECT 111
#define ZM_MESSAGE_BODY 112
#define ZM_NEW_MAIL_MODULES 113
#define ZM_EMAIL_HOST 114
#define ZM_FROM_EMAIL 115
#define ZM_URL 116
#define ZM_MAX_RESTART_DELAY 117
#define ZM_WATCH_CHECK_INTERVAL 118
#define ZM_WATCH_MAX_DELAY 119
#define ZM_RUN_AUDIT 120
#define ZM_AUDIT_CHECK_INTERVAL 121
#define ZM_FORCED_ALARM_SCORE 122
#define ZM_BULK_FRAME_INTERVAL 123
#define ZM_EVENT_CLOSE_MODE 124
#define ZM_FORCE_CLOSE_EVENTS 125
#define ZM_CREATE_ANALYSIS_IMAGES 126
#define ZM_WEIGHTED_ALARM_CENTRES 127
#define ZM_EVENT_IMAGE_DIGITS 128
#define ZM_DEFAULT_ASPECT_RATIO 129
#define ZM_USER_SELF_EDIT 130
#define ZM_OPT_FRAME_SERVER 131
#define ZM_FRAME_SOCKET_SIZE 132
#define ZM_OPT_CONTROL 133
#define ZM_OPT_TRIGGERS 134
#define ZM_CHECK_FOR_UPDATES 135
#define ZM_UPDATE_CHECK_PROXY 136
#define ZM_SHM_KEY 137
#define ZM_WEB_REFRESH_METHOD 138
#define ZM_WEB_EVENT_SORT_FIELD 139
#define ZM_WEB_EVENT_SORT_ORDER 140
#define ZM_WEB_EVENTS_PER_PAGE 141
#define ZM_WEB_LIST_THUMBS 142
#define ZM_WEB_LIST_THUMB_WIDTH 143
#define ZM_WEB_LIST_THUMB_HEIGHT 144
#define ZM_WEB_USE_OBJECT_TAGS 145
#define ZM_WEB_H_REFRESH_MAIN 146
#define ZM_WEB_H_REFRESH_CYCLE 147
#define ZM_WEB_H_REFRESH_IMAGE 148
#define ZM_WEB_H_REFRESH_STATUS 149
#define ZM_WEB_H_REFRESH_EVENTS 150
#define ZM_WEB_H_CAN_STREAM 151
#define ZM_WEB_H_STREAM_METHOD 152
#define ZM_WEB_H_DEFAULT_SCALE 153
#define ZM_WEB_H_DEFAULT_RATE 154
#define ZM_WEB_H_VIDEO_BITRATE 155
#define ZM_WEB_H_VIDEO_MAXFPS 156
#define ZM_WEB_H_SCALE_THUMBS 157
#define ZM_WEB_H_EVENTS_VIEW 158
#define ZM_WEB_H_SHOW_PROGRESS 159
#define ZM_WEB_H_AJAX_TIMEOUT 160
#define ZM_WEB_M_REFRESH_MAIN 161
#define ZM_WEB_M_REFRESH_CYCLE 162
#define ZM_WEB_M_REFRESH_IMAGE 163
#define ZM_WEB_M_REFRESH_STATUS 164
#define ZM_WEB_M_REFRESH_EVENTS 165
#define ZM_WEB_M_CAN_STREAM 166
#define ZM_WEB_M_STREAM_METHOD 167
#define ZM_WEB_M_DEFAULT_SCALE 168
#define ZM_WEB_M_DEFAULT_RATE 169
#define ZM_WEB_M_VIDEO_BITRATE 170
#define ZM_WEB_M_VIDEO_MAXFPS 171
#define ZM_WEB_M_SCALE_THUMBS 172
#define ZM_WEB_M_EVENTS_VIEW 173
#define ZM_WEB_M_SHOW_PROGRESS 174
#define ZM_WEB_M_AJAX_TIMEOUT 175
#define ZM_WEB_L_REFRESH_MAIN 176
#define ZM_WEB_L_REFRESH_CYCLE 177
#define ZM_WEB_L_REFRESH_IMAGE 178
#define ZM_WEB_L_REFRESH_STATUS 179
#define ZM_WEB_L_REFRESH_EVENTS 180
#define ZM_WEB_L_CAN_STREAM 181
#define ZM_WEB_L_STREAM_METHOD 182
#define ZM_WEB_L_DEFAULT_SCALE 183
#define ZM_WEB_L_DEFAULT_RATE 184
#define ZM_WEB_L_VIDEO_BITRATE 185
#define ZM_WEB_L_VIDEO_MAXFPS 186
#define ZM_WEB_L_SCALE_THUMBS 187
#define ZM_WEB_L_EVENTS_VIEW 188
#define ZM_WEB_L_SHOW_PROGRESS 189
#define ZM_WEB_L_AJAX_TIMEOUT 190
#define ZM_WEB_P_CAN_STREAM 191
#define ZM_WEB_P_STREAM_METHOD 192
#define ZM_WEB_P_DEFAULT_SCALE 193
#define ZM_WEB_P_DEFAULT_RATE 194
#define ZM_WEB_P_VIDEO_BITRATE 195
#define ZM_WEB_P_VIDEO_MAXFPS 196
#define ZM_WEB_P_SCALE_THUMBS 197
#define ZM_WEB_P_AJAX_TIMEOUT 198
#define ZM_DYN_LAST_VERSION 199
#define ZM_DYN_CURR_VERSION 200
#define ZM_DYN_DB_VERSION 201
#define ZM_DYN_LAST_CHECK 202
#define ZM_DYN_NEXT_REMINDER 203
#define ZM_DYN_DONATE_REMINDER_TIME 204
#define ZM_DYN_SHOW_DONATE_REMINDER 205
#define ZM_EYEZM_DEBUG 206
#define ZM_EYEZM_LOG_TO_FILE 207
#define ZM_EYEZM_LOG_FILE 208
#define ZM_EYEZM_EVENT_VCODEC 209
#define ZM_EYEZM_FEED_VCODEC 210
#define ZM_EYEZM_H264_DEFAULT_BR 211
#define ZM_EYEZM_H264_DEFAULT_EVBR 212
#define ZM_EYEZM_H264_TIMEOUT 213
#define ZM_EYEZM_SEG_DURATION 214
#define ZM_MAX_CFG_ID 215
#define ZM_MAX_CFG_ID 214
#define ZM_CFG_DECLARE_LIST \
const char *lang_default;\
@ -251,7 +250,6 @@
bool cpu_extensions;\
bool fast_image_blends;\
bool opt_adaptive_skip;\
bool blend_alarmed_images;\
int max_suspend_time;\
bool opt_remote_cameras;\
bool netcam_regexps;\
@ -470,7 +468,6 @@
cpu_extensions = (bool)config.Item( ZM_CPU_EXTENSIONS );\
fast_image_blends = (bool)config.Item( ZM_FAST_IMAGE_BLENDS );\
opt_adaptive_skip = (bool)config.Item( ZM_OPT_ADAPTIVE_SKIP );\
blend_alarmed_images = (bool)config.Item( ZM_BLEND_ALARMED_IMAGES );\
max_suspend_time = (int)config.Item( ZM_MAX_SUSPEND_TIME );\
opt_remote_cameras = (bool)config.Item( ZM_OPT_REMOTE_CAMERAS );\
netcam_regexps = (bool)config.Item( ZM_NETCAM_REGEXPS );\