Allowed no .conf file to be present

git-svn-id: http://svn.zoneminder.com/svn/zm/trunk@1244 e3e1d417-86f3-4887-817a-d78f3d33393f
This commit is contained in:
stan 2005-01-26 20:56:47 +00:00
parent 76bc4cb613
commit f2275b3131
1 changed files with 23 additions and 12 deletions

View File

@ -43,22 +43,28 @@ BEGIN
{
no strict 'refs';
open( CONFIG, "<".ZM_CONFIG ) or die( "Can't open config file: $!" );
foreach my $str ( <CONFIG> )
if ( open( CONFIG, "<".ZM_CONFIG ) )
{
next if ( $str =~ /^\s*$/ );
next if ( $str =~ /^\s*#/ );
my ( $name, $value ) = $str =~ /^\s*([^=\s]+)\s*=\s*([^=\s]+)\s*$/;
$name =~ tr/a-z/A-Z/;
if (( $name eq 'ZM_DB_SERVER' ) ||
( $name eq 'ZM_DB_NAME' ) ||
( $name eq 'ZM_DB_USER' ) ||
( $name eq 'ZM_DB_PASS' ))
foreach my $str ( <CONFIG> )
{
*{$name} = sub { $value };
next if ( $str =~ /^\s*$/ );
next if ( $str =~ /^\s*#/ );
my ( $name, $value ) = $str =~ /^\s*([^=\s]+)\s*=\s*([^=\s]+)\s*$/;
$name =~ tr/a-z/A-Z/;
if (( $name eq 'ZM_DB_SERVER' ) ||
( $name eq 'ZM_DB_NAME' ) ||
( $name eq 'ZM_DB_USER' ) ||
( $name eq 'ZM_DB_PASS' ))
{
*{$name} = sub { $value };
}
}
close( CONFIG );
}
else
{
warn( "Can't open config file: $!" );
}
close( CONFIG );
use DBI;
my $dbh = DBI->connect( "DBI:mysql:database=".&ZM_DB_NAME.";host=".&ZM_DB_SERVER, &ZM_DB_USER, &ZM_DB_PASS );
@ -71,6 +77,11 @@ BEGIN
}
$sth->finish();
$dbh->disconnect();
if ( !ZM_DB_USER )
{
*ZM_DB_USER = sub { ZM_DB_USERA };
*ZM_DB_PASS = sub { ZM_DB_PASSA };
}
}
use constant UPDATE_LOG_FILE => ZM_PATH_LOGS.'/zmupdate.log';