Bug 232 - Moved use of constants to after include of ZoneMinder package

git-svn-id: http://svn.zoneminder.com/svn/zm/trunk@1681 e3e1d417-86f3-4887-817a-d78f3d33393f
This commit is contained in:
stan 2005-12-16 10:36:22 +00:00
parent 786488a990
commit b6b382a487
15 changed files with 60 additions and 43 deletions

View File

@ -38,7 +38,6 @@ use bytes;
# #
# ========================================================================== # ==========================================================================
use constant LOG_FILE => ZM_PATH_LOGS.'/zmaudit.log';
use constant MIN_AGE => 300; # Minimum age when we will delete anything use constant MIN_AGE => 300; # Minimum age when we will delete anything
use constant RECOVER_TAG => "(r)"; # Tag to append to event name when recovered use constant RECOVER_TAG => "(r)"; # Tag to append to event name when recovered
use constant RECOVER_TEXT => "Recovered."; # Text to append to event notes when recovered use constant RECOVER_TEXT => "Recovered."; # Text to append to event notes when recovered
@ -57,6 +56,7 @@ use POSIX;
use Time::HiRes qw/gettimeofday/; use Time::HiRes qw/gettimeofday/;
use Getopt::Long; use Getopt::Long;
use constant LOG_FILE => ZM_PATH_LOGS.'/zmaudit.log';
use constant IMAGE_PATH => ZM_PATH_WEB.'/'.ZM_DIR_IMAGES; use constant IMAGE_PATH => ZM_PATH_WEB.'/'.ZM_DIR_IMAGES;
use constant EVENT_PATH => ZM_PATH_WEB.'/'.ZM_DIR_EVENTS; use constant EVENT_PATH => ZM_PATH_WEB.'/'.ZM_DIR_EVENTS;
@ -222,7 +222,7 @@ if ( $report && $yes )
usage(); usage();
} }
my $dbh = DBI->connect( "DBI:mysql:database=".ZM_DB_NAME.";host=".ZM_DB_SERVER, ZM_DB_USER, ZM_DB_PASS ); my $dbh = DBI->connect( "DBI:mysql:database=".ZM_DB_NAME.";host=".ZM_DB_HOST, ZM_DB_USER, ZM_DB_PASS );
chdir( EVENT_PATH ); chdir( EVENT_PATH );
if ( $delay ) # Background mode if ( $delay ) # Background mode

View File

@ -33,7 +33,7 @@ use strict;
# #
# ========================================================================== # ==========================================================================
use constant LOG_FILE => ZM_PATH_LOGS.'/zmcontrol-axis-v2.log'; # None
# ========================================================================== # ==========================================================================
@ -41,6 +41,8 @@ use ZoneMinder;
use Getopt::Long; use Getopt::Long;
use Device::SerialPort; use Device::SerialPort;
use constant LOG_FILE => ZM_PATH_LOGS.'/zmcontrol-axis-v2.log';
$| = 1; $| = 1;
$ENV{PATH} = '/bin:/usr/bin'; $ENV{PATH} = '/bin:/usr/bin';

View File

@ -33,7 +33,7 @@ use strict;
# #
# ========================================================================== # ==========================================================================
use constant LOG_FILE => ZM_PATH_LOGS.'/zmcontrol-kx-hcm10.log'; # None
# ========================================================================== # ==========================================================================
@ -41,6 +41,8 @@ use ZoneMinder;
use Getopt::Long; use Getopt::Long;
use Device::SerialPort; use Device::SerialPort;
use constant LOG_FILE => ZM_PATH_LOGS.'/zmcontrol-kx-hcm10.log';
$| = 1; $| = 1;
$ENV{PATH} = '/bin:/usr/bin'; $ENV{PATH} = '/bin:/usr/bin';

View File

@ -33,7 +33,7 @@ use strict;
# #
# ========================================================================== # ==========================================================================
use constant LOG_FILE => ZM_PATH_LOGS.'/zmcontrol-pelco-d.log'; # None
# ========================================================================== # ==========================================================================
@ -42,6 +42,8 @@ use Getopt::Long;
use Device::SerialPort; use Device::SerialPort;
use Time::HiRes qw( usleep ); use Time::HiRes qw( usleep );
use constant LOG_FILE => ZM_PATH_LOGS.'/zmcontrol-pelco-d.log';
$| = 1; $| = 1;
$ENV{PATH} = '/bin:/usr/bin'; $ENV{PATH} = '/bin:/usr/bin';

View File

@ -33,7 +33,7 @@ use strict;
# #
# ========================================================================== # ==========================================================================
use constant LOG_FILE => ZM_PATH_LOGS.'/zmcontrol-pelco-p.log'; # None
# ========================================================================== # ==========================================================================
@ -43,6 +43,8 @@ use Getopt::Long;
use Device::SerialPort; use Device::SerialPort;
use Time::HiRes qw( usleep ); use Time::HiRes qw( usleep );
use constant LOG_FILE => ZM_PATH_LOGS.'/zmcontrol-pelco-p.log';
$| = 1; $| = 1;
$ENV{PATH} = '/bin:/usr/bin'; $ENV{PATH} = '/bin:/usr/bin';

View File

@ -33,7 +33,7 @@ use strict;
# #
# ========================================================================== # ==========================================================================
use constant LOG_FILE => ZM_PATH_LOGS.'/zmcontrol-visca.log'; # None
# ========================================================================== # ==========================================================================
@ -41,6 +41,8 @@ use ZoneMinder;
use Getopt::Long; use Getopt::Long;
use Device::SerialPort; use Device::SerialPort;
use constant LOG_FILE => ZM_PATH_LOGS.'/zmcontrol-visca.log';
$| = 1; $| = 1;
$ENV{PATH} = '/bin:/usr/bin'; $ENV{PATH} = '/bin:/usr/bin';

View File

@ -36,8 +36,6 @@ use bytes;
# #
# ========================================================================== # ==========================================================================
use constant DC_SOCK_FILE => ZM_PATH_SOCKS.'/zmdc.sock';
use constant DC_LOG_FILE => ZM_PATH_LOGS.'/zmdc.log';
use constant MAX_CONNECT_DELAY => 10; use constant MAX_CONNECT_DELAY => 10;
use constant VERBOSE => 0; # Whether to output more verbose debug use constant VERBOSE => 0; # Whether to output more verbose debug
@ -53,6 +51,9 @@ use Socket;
use IO::Handle; use IO::Handle;
use Data::Dumper; use Data::Dumper;
use constant DC_SOCK_FILE => ZM_PATH_SOCKS.'/zmdc.sock';
use constant DC_LOG_FILE => ZM_PATH_LOGS.'/zmdc.log';
$| = 1; $| = 1;
$ENV{PATH} = '/bin:/usr/bin'; $ENV{PATH} = '/bin:/usr/bin';

View File

@ -34,11 +34,26 @@ use bytes;
# #
# ========================================================================== # ==========================================================================
use constant LOG_FILE => ZM_PATH_LOGS.'/zmfilter.log';
use constant START_DELAY => 5; # How long to wait before starting use constant START_DELAY => 5; # How long to wait before starting
use constant DBG_LEVEL => 0; # 0 is errors, warnings and info only, > 0 for debug use constant DBG_LEVEL => 0; # 0 is errors, warnings and info only, > 0 for debug
# ==========================================================================
#
# You shouldn't need to change anything from here downwards
#
# ==========================================================================
use ZoneMinder;
use DBI;
use POSIX;
use Time::HiRes qw/gettimeofday/;
use Date::Manip;
use Data::Dumper;
use Getopt::Long;
use constant EVENT_PATH => ZM_PATH_WEB.'/'.ZM_DIR_EVENTS;
use constant LOG_FILE => ZM_PATH_LOGS.'/zmfilter.log';
if ( ZM_OPT_UPLOAD ) if ( ZM_OPT_UPLOAD )
{ {
# Comment these out if you don't have them and don't want to upload # Comment these out if you don't have them and don't want to upload
@ -88,21 +103,6 @@ if ( ZM_OPT_MESSAGE )
( $message_subject, $message_body ) = ZM_MESSAGE_TEXT =~ /subject\s*=\s*"([^\n]*)".*body\s*=\s*"(.*)"/ms; ( $message_subject, $message_body ) = ZM_MESSAGE_TEXT =~ /subject\s*=\s*"([^\n]*)".*body\s*=\s*"(.*)"/ms;
} }
# ==========================================================================
#
# You shouldn't need to change anything from here downwards
#
# ==========================================================================
use ZoneMinder;
use DBI;
use POSIX;
use Time::HiRes qw/gettimeofday/;
use Date::Manip;
use Data::Dumper;
use Getopt::Long;
use constant EVENT_PATH => ZM_PATH_WEB.'/'.ZM_DIR_EVENTS;
$| = 1; $| = 1;

View File

@ -33,7 +33,6 @@ use bytes;
# #
# ========================================================================== # ==========================================================================
use constant LOG_FILE => ZM_PATH_LOGS.'/zmpkg.log';
use constant DBG_LEVEL => 0; # 0 is errors, warnings and info only, > 0 for debug use constant DBG_LEVEL => 0; # 0 is errors, warnings and info only, > 0 for debug
# ========================================================================== # ==========================================================================
@ -47,6 +46,8 @@ use DBI;
use POSIX; use POSIX;
use Time::HiRes qw/gettimeofday/; use Time::HiRes qw/gettimeofday/;
use constant LOG_FILE => ZM_PATH_LOGS.'/zmpkg.log';
# Detaint our environment # Detaint our environment
$ENV{PATH} = '/bin:/usr/bin'; $ENV{PATH} = '/bin:/usr/bin';
$ENV{SHELL} = '/bin/sh' if exists $ENV{SHELL}; $ENV{SHELL} = '/bin/sh' if exists $ENV{SHELL};
@ -56,7 +57,7 @@ my $command = $ARGV[0];
my $state; my $state;
my $dbh = DBI->connect( "DBI:mysql:database=".ZM_DB_NAME.";host=".ZM_DB_SERVER, ZM_DB_USER, ZM_DB_PASS ); my $dbh = DBI->connect( "DBI:mysql:database=".ZM_DB_NAME.";host=".ZM_DB_HOST, ZM_DB_USER, ZM_DB_PASS );
if ( !$command || $command !~ /^(?:start|stop|restart|status)$/ ) if ( !$command || $command !~ /^(?:start|stop|restart|status)$/ )
{ {

View File

@ -33,7 +33,6 @@ use bytes;
# #
# ========================================================================== # ==========================================================================
use constant LOG_FILE => ZM_PATH_LOGS.'/zmtrack-%s.log';
use constant SLEEP_TIME => 10000; # In microseconds use constant SLEEP_TIME => 10000; # In microseconds
use constant VERBOSE => 1; # Whether to output more verbose debug use constant VERBOSE => 1; # Whether to output more verbose debug
@ -50,6 +49,8 @@ use Data::Dumper;
use Getopt::Long; use Getopt::Long;
use Time::HiRes qw( usleep ); use Time::HiRes qw( usleep );
use constant LOG_FILE => ZM_PATH_LOGS.'/zmtrack-%s.log';
$| = 1; $| = 1;
$ENV{PATH} = '/bin:/usr/bin'; $ENV{PATH} = '/bin:/usr/bin';

View File

@ -33,7 +33,6 @@ use bytes;
# #
# ========================================================================== # ==========================================================================
use constant LOG_FILE => ZM_PATH_LOGS.'/zmtrigger.log';
use constant MAX_CONNECT_DELAY => 10; use constant MAX_CONNECT_DELAY => 10;
use constant VERBOSE => 0; # Whether to output more verbose debug use constant VERBOSE => 0; # Whether to output more verbose debug
@ -65,6 +64,8 @@ use Socket;
use IO::Handle; use IO::Handle;
use Data::Dumper; use Data::Dumper;
use constant LOG_FILE => ZM_PATH_LOGS.'/zmtrigger.log';
$| = 1; $| = 1;
$ENV{PATH} = '/bin:/usr/bin'; $ENV{PATH} = '/bin:/usr/bin';

View File

@ -34,7 +34,6 @@ use bytes;
# #
# ========================================================================== # ==========================================================================
use constant UPDATE_LOG_FILE => ZM_PATH_LOGS.'/zmupdate.log';
use constant CHECK_INTERVAL => (1*24*60*60); # Interval between version checks use constant CHECK_INTERVAL => (1*24*60*60); # Interval between version checks
use constant VERBOSE => 0; # Whether to output more verbose debug use constant VERBOSE => 0; # Whether to output more verbose debug
@ -51,6 +50,7 @@ use Getopt::Long;
use Data::Dumper; use Data::Dumper;
use constant EVENT_PATH => ZM_PATH_WEB.'/'.ZM_DIR_EVENTS; use constant EVENT_PATH => ZM_PATH_WEB.'/'.ZM_DIR_EVENTS;
use constant UPDATE_LOG_FILE => ZM_PATH_LOGS.'/zmupdate.log';
$| = 1; $| = 1;
@ -110,7 +110,7 @@ print( "Update agent starting at ".strftime( '%y/%m/%d %H:%M:%S', localtime() ).
if ( $check && ZM_CHECK_FOR_UPDATES ) if ( $check && ZM_CHECK_FOR_UPDATES )
{ {
my $dbh = DBI->connect( "DBI:mysql:database=".ZM_DB_NAME.";host=".ZM_DB_SERVER, ZM_DB_USER, ZM_DB_PASS ); my $dbh = DBI->connect( "DBI:mysql:database=".ZM_DB_NAME.";host=".ZM_DB_HOST, ZM_DB_USER, ZM_DB_PASS );
my $curr_version = ZM_DYN_CURR_VERSION; my $curr_version = ZM_DYN_CURR_VERSION;
my $last_version = ZM_DYN_LAST_VERSION; my $last_version = ZM_DYN_LAST_VERSION;
@ -148,7 +148,7 @@ if ( $check && ZM_CHECK_FOR_UPDATES )
print( "Got version: '".$last_version."'\n" ); print( "Got version: '".$last_version."'\n" );
my $dbh = DBI->connect( "DBI:mysql:database=".ZM_DB_NAME.";host=".ZM_DB_SERVER, ZM_DB_USER, ZM_DB_PASS ); my $dbh = DBI->connect( "DBI:mysql:database=".ZM_DB_NAME.";host=".ZM_DB_HOST, ZM_DB_USER, ZM_DB_PASS );
my $lv_sql = "update Config set Value = ? where Name = 'ZM_DYN_LAST_VERSION'"; my $lv_sql = "update Config set Value = ? where Name = 'ZM_DYN_LAST_VERSION'";
my $lv_sth = $dbh->prepare_cached( $lv_sql ) or die( "Can't prepare '$lv_sql': ".$dbh->errstr() ); my $lv_sth = $dbh->prepare_cached( $lv_sql ) or die( "Can't prepare '$lv_sql': ".$dbh->errstr() );
@ -200,7 +200,7 @@ if ( $zone_fix )
{ {
require DBI; require DBI;
my $dbh = DBI->connect( "DBI:mysql:database=".ZM_DB_NAME.";host=".ZM_DB_SERVER, ZM_DB_USER, ZM_DB_PASS ); my $dbh = DBI->connect( "DBI:mysql:database=".ZM_DB_NAME.";host=".ZM_DB_HOST, ZM_DB_USER, ZM_DB_PASS );
my $sql = "select Z.*, M.Width as MonitorWidth, M.Height as MonitorHeight from Zones as Z inner join Monitors as M on Z.MonitorId = M.Id where Z.Units = 'Percent'"; my $sql = "select Z.*, M.Width as MonitorWidth, M.Height as MonitorHeight from Zones as Z inner join Monitors as M on Z.MonitorId = M.Id where Z.Units = 'Percent'";
my $sth = $dbh->prepare_cached( $sql ) or die( "Can't prepare '$sql': ".$dbh->errstr() ); my $sth = $dbh->prepare_cached( $sql ) or die( "Can't prepare '$sql': ".$dbh->errstr() );
@ -255,7 +255,7 @@ if ( $version )
if ( $response =~ /^[yY]$/ ) if ( $response =~ /^[yY]$/ )
{ {
my $command = "mysqldump -h".ZM_DB_SERVER; my $command = "mysqldump -h".ZM_DB_HOST;
if ( $db_user ) if ( $db_user )
{ {
$command .= " -u".$db_user; $command .= " -u".$db_user;
@ -295,7 +295,7 @@ if ( $version )
my $dbh = shift; my $dbh = shift;
my $version = shift; my $version = shift;
my $command = "mysql -h".ZM_DB_SERVER; my $command = "mysql -h".ZM_DB_HOST;
if ( $db_user ) if ( $db_user )
{ {
$command .= " -u".$db_user; $command .= " -u".$db_user;
@ -334,7 +334,7 @@ if ( $version )
print( "\nUpgrading database to version ".ZM_VERSION."\n" ); print( "\nUpgrading database to version ".ZM_VERSION."\n" );
my $dbh = DBI->connect( "DBI:mysql:database=".ZM_DB_NAME.";host=".ZM_DB_SERVER, ZM_DB_USER, ZM_DB_PASS ); my $dbh = DBI->connect( "DBI:mysql:database=".ZM_DB_NAME.";host=".ZM_DB_HOST, ZM_DB_USER, ZM_DB_PASS );
my $cascade = undef; my $cascade = undef;
if ( $cascade || $version eq "1.19.0" ) if ( $cascade || $version eq "1.19.0" )

View File

@ -33,7 +33,6 @@ use bytes;
# #
# ========================================================================== # ==========================================================================
use constant LOG_FILE => ZM_PATH_LOGS.'/zmvideo.log';
use constant VERBOSE => 0; # Whether to output more verbose debug use constant VERBOSE => 0; # Whether to output more verbose debug
# ========================================================================== # ==========================================================================
@ -47,6 +46,8 @@ use DBI;
use Data::Dumper; use Data::Dumper;
use Getopt::Long qw(:config no_ignore_case ); use Getopt::Long qw(:config no_ignore_case );
use constant LOG_FILE => ZM_PATH_LOGS.'/zmvideo.log';
$| = 1; $| = 1;
$ENV{PATH} = '/bin:/usr/bin'; $ENV{PATH} = '/bin:/usr/bin';
@ -163,7 +164,7 @@ open( STDERR, ">&LOG" ) || die( "Can't dup stderr: $!" );
select( STDERR ); $| = 1; select( STDERR ); $| = 1;
select( LOG ); $| = 1; select( LOG ); $| = 1;
my $dbh = DBI->connect( "DBI:mysql:database=".ZM_DB_NAME.";host=".ZM_DB_SERVER, ZM_DB_USER, ZM_DB_PASS ); my $dbh = DBI->connect( "DBI:mysql:database=".ZM_DB_NAME.";host=".ZM_DB_HOST, ZM_DB_USER, ZM_DB_PASS );
my @filters; my @filters;
my $sql = "select max(F.Delta)-min(F.Delta) as FullLength, E.*, M.Name as MonitorName, M.Width as MonitorWidth, M.Height as MonitorHeight, M.Palette from Frames as F inner join Events as E on F.EventId = E.Id inner join Monitors as M on E.MonitorId = M.Id where EventId = '$event_id' group by F.EventId"; my $sql = "select max(F.Delta)-min(F.Delta) as FullLength, E.*, M.Name as MonitorName, M.Width as MonitorWidth, M.Height as MonitorHeight, M.Palette from Frames as F inner join Events as E on F.EventId = E.Id inner join Monitors as M on E.MonitorId = M.Id where EventId = '$event_id' group by F.EventId";

View File

@ -34,7 +34,6 @@ use bytes;
# #
# ========================================================================== # ==========================================================================
use constant WATCH_LOG_FILE => ZM_PATH_LOGS.'/zmwatch.log';
use constant START_DELAY => 30; # To give everything else time to start use constant START_DELAY => 30; # To give everything else time to start
use constant VERBOSE => 0; # Whether to output more verbose debug use constant VERBOSE => 0; # Whether to output more verbose debug
@ -49,6 +48,8 @@ use POSIX;
use DBI; use DBI;
use Data::Dumper; use Data::Dumper;
use constant WATCH_LOG_FILE => ZM_PATH_LOGS.'/zmwatch.log';
$| = 1; $| = 1;
$ENV{PATH} = '/bin:/usr/bin'; $ENV{PATH} = '/bin:/usr/bin';
@ -73,7 +74,7 @@ print( "Watchdog starting at ".strftime( '%y/%m/%d %H:%M:%S', localtime() )."\n"
print( "Watchdog pausing for ".START_DELAY." seconds\n" ); print( "Watchdog pausing for ".START_DELAY." seconds\n" );
sleep( START_DELAY ); sleep( START_DELAY );
my $dbh = DBI->connect( "DBI:mysql:database=".ZM_DB_NAME.";host=".ZM_DB_SERVER, ZM_DB_USER, ZM_DB_PASS ); my $dbh = DBI->connect( "DBI:mysql:database=".ZM_DB_NAME.";host=".ZM_DB_HOST, ZM_DB_USER, ZM_DB_PASS );
my $sql = "select * from Monitors"; my $sql = "select * from Monitors";
my $sth = $dbh->prepare_cached( $sql ) or die( "Can't prepare '$sql': ".$dbh->errstr() ); my $sth = $dbh->prepare_cached( $sql ) or die( "Can't prepare '$sql': ".$dbh->errstr() );

View File

@ -33,8 +33,6 @@ use bytes;
# #
# ========================================================================== # ==========================================================================
use constant X10_SOCK_FILE => ZM_PATH_SOCKS.'/zmx10.sock';
use constant X10_LOG_FILE => ZM_PATH_LOGS.'/zmx10.log';
use constant VERBOSE => 0; # Whether to output more verbose debug use constant VERBOSE => 0; # Whether to output more verbose debug
# ========================================================================== # ==========================================================================
@ -49,6 +47,9 @@ use Socket;
use Getopt::Long; use Getopt::Long;
use Data::Dumper; use Data::Dumper;
use constant X10_SOCK_FILE => ZM_PATH_SOCKS.'/zmx10.sock';
use constant X10_LOG_FILE => ZM_PATH_LOGS.'/zmx10.log';
$| = 1; $| = 1;
$ENV{PATH} = '/bin:/usr/bin'; $ENV{PATH} = '/bin:/usr/bin';