From 2ba1ee4eb8eaaea48026c5f20b993bb8caed7ef3 Mon Sep 17 00:00:00 2001 From: stan Date: Tue, 28 Dec 2004 17:01:25 +0000 Subject: [PATCH] Removed secondary DB user. git-svn-id: http://svn.zoneminder.com/svn/zm/trunk@1171 e3e1d417-86f3-4887-817a-d78f3d33393f --- scripts/zmaudit.pl.z | 10 ++++------ scripts/zmdc.pl.z | 14 ++++++-------- scripts/zmfilter.pl.z | 16 +++++++--------- scripts/zmpkg.pl.z | 10 ++++------ scripts/zmupdate.pl.z | 24 +++++++++++------------- scripts/zmvideo.pl.z | 16 +++++++--------- scripts/zmwatch.pl.z | 16 +++++++--------- scripts/zmx10.pl.z | 16 +++++++--------- src/zm_config.cpp | 8 +++----- src/zm_config.h.z | 2 +- src/zm_db.cpp | 4 ++-- src/zm_db.h | 2 +- src/zma.cpp | 2 +- src/zmc.cpp | 2 +- src/zmf.cpp | 2 +- src/zmfix.cpp | 2 +- src/zms.cpp | 2 +- src/zmu.cpp | 2 +- web/zm_config.php.z | 25 +++++++++++-------------- zm.conf.z | 7 ++----- zmconfig.pl.in | 32 ++++++++------------------------ 21 files changed, 87 insertions(+), 127 deletions(-) diff --git a/scripts/zmaudit.pl.z b/scripts/zmaudit.pl.z index 5b8028981..c0ec97730 100755 --- a/scripts/zmaudit.pl.z +++ b/scripts/zmaudit.pl.z @@ -51,10 +51,8 @@ BEGIN $name =~ tr/a-z/A-Z/; if (( $name eq 'ZM_DB_SERVER' ) || ( $name eq 'ZM_DB_NAME' ) || - ( $name eq 'ZM_DB_USERA' ) || - ( $name eq 'ZM_DB_PASSA' ) || - ( $name eq 'ZM_DB_USERB' ) || - ( $name eq 'ZM_DB_PASSB' ) + ( $name eq 'ZM_DB_USER' ) || + ( $name eq 'ZM_DB_PASS' ) { *{$name} = sub { $value }; } @@ -63,7 +61,7 @@ BEGIN use DBI; no strict 'refs'; - my $dbh = DBI->connect( "DBI:mysql:database=".&ZM_DB_NAME.";host=".&ZM_DB_SERVER, &ZM_DB_USERA, &ZM_DB_PASSA ); + my $dbh = DBI->connect( "DBI:mysql:database=".&ZM_DB_NAME.";host=".&ZM_DB_SERVER, &ZM_DB_USER, &ZM_DB_PASS ); my $sql = "select * from Config"; my $sth = $dbh->prepare_cached( $sql ) or die( "Can't prepare '$sql': ".$dbh->errstr() ); @@ -161,7 +159,7 @@ if ( $report && $yes ) usage(); } -my $dbh = DBI->connect( "DBI:mysql:database=".ZM_DB_NAME.";host=".ZM_DB_SERVER, ZM_DB_USERA, ZM_DB_PASSA ); +my $dbh = DBI->connect( "DBI:mysql:database=".ZM_DB_NAME.";host=".ZM_DB_SERVER, ZM_DB_USER, ZM_DB_PASS ); chdir( EVENT_PATH ); if ( $delay ) # Background mode diff --git a/scripts/zmdc.pl.z b/scripts/zmdc.pl.z index 2ea4e3cf7..734ab4538 100755 --- a/scripts/zmdc.pl.z +++ b/scripts/zmdc.pl.z @@ -45,16 +45,14 @@ BEGIN open( CONFIG, "<".ZM_CONFIG ) or die( "Can't open config file: $!" ); foreach my $str ( ) { - next if ( $str =~ /^\s*$/ ); - next if ( $str =~ /^\s*#/ ); - my ( $name, $value ) = $str =~ /^\s*([^=\s]+)\s*=\s*([^=\s]+)\s*$/; + 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_USERA' ) || - ( $name eq 'ZM_DB_PASSA' ) || - ( $name eq 'ZM_DB_USERB' ) || - ( $name eq 'ZM_DB_PASSB' )) + ( $name eq 'ZM_DB_USER' ) || + ( $name eq 'ZM_DB_PASS' )) { *{$name} = sub { $value }; } @@ -63,7 +61,7 @@ BEGIN use DBI; no strict 'refs'; - my $dbh = DBI->connect( "DBI:mysql:database=".&ZM_DB_NAME.";host=".&ZM_DB_SERVER, &ZM_DB_USERA, &ZM_DB_PASSA ); + my $dbh = DBI->connect( "DBI:mysql:database=".&ZM_DB_NAME.";host=".&ZM_DB_SERVER, &ZM_DB_USER, &ZM_DB_PASS ); my $sql = "select * from Config"; my $sth = $dbh->prepare_cached( $sql ) or die( "Can't prepare '$sql': ".$dbh->errstr() ); diff --git a/scripts/zmfilter.pl.z b/scripts/zmfilter.pl.z index ef4a0ab0f..b92ee0588 100755 --- a/scripts/zmfilter.pl.z +++ b/scripts/zmfilter.pl.z @@ -43,16 +43,14 @@ BEGIN open( CONFIG, "<".ZM_CONFIG ) or die( "Can't open config file: $!" ); foreach my $str ( ) { - next if ( $str =~ /^\s*$/ ); - next if ( $str =~ /^\s*#/ ); - my ( $name, $value ) = $str =~ /^\s*([^=\s]+)\s*=\s*([^=\s]+)\s*$/; + 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_USERA' ) || - ( $name eq 'ZM_DB_PASSA' ) || - ( $name eq 'ZM_DB_USERB' ) || - ( $name eq 'ZM_DB_PASSB' )) + ( $name eq 'ZM_DB_USER' ) || + ( $name eq 'ZM_DB_PASS' )) { *{$name} = sub { $value }; } @@ -61,7 +59,7 @@ BEGIN use DBI; no strict 'refs'; - my $dbh = DBI->connect( "DBI:mysql:database=".&ZM_DB_NAME.";host=".&ZM_DB_SERVER, &ZM_DB_USERA, &ZM_DB_PASSA ); + my $dbh = DBI->connect( "DBI:mysql:database=".&ZM_DB_NAME.";host=".&ZM_DB_SERVER, &ZM_DB_USER, &ZM_DB_PASS ); my $sql = "select * from Config"; my $sth = $dbh->prepare_cached( $sql ) or die( "Can't prepare '$sql': ".$dbh->errstr() ); @@ -192,7 +190,7 @@ select( LOG ); $| = 1; chdir( EVENT_PATH ); -my $dbh = DBI->connect( "DBI:mysql:database=".ZM_DB_NAME.";host=".ZM_DB_SERVER, ZM_DB_USERA, ZM_DB_PASSA ); +my $dbh = DBI->connect( "DBI:mysql:database=".ZM_DB_NAME.";host=".ZM_DB_SERVER, ZM_DB_USER, ZM_DB_PASS ); print( "Scanning for events\n" ); diff --git a/scripts/zmpkg.pl.z b/scripts/zmpkg.pl.z index cbf07a7c6..eb4d83ffa 100755 --- a/scripts/zmpkg.pl.z +++ b/scripts/zmpkg.pl.z @@ -50,10 +50,8 @@ BEGIN $name =~ tr/a-z/A-Z/; if (( $name eq 'ZM_DB_SERVER' ) || ( $name eq 'ZM_DB_NAME' ) || - ( $name eq 'ZM_DB_USERA' ) || - ( $name eq 'ZM_DB_PASSA' ) || - ( $name eq 'ZM_DB_USERB' ) || - ( $name eq 'ZM_DB_PASSB' )) + ( $name eq 'ZM_DB_USER' ) || + ( $name eq 'ZM_DB_PASS' )) { *{$name} = sub { $value }; } @@ -62,7 +60,7 @@ BEGIN use DBI; no strict 'refs'; - my $dbh = DBI->connect( "DBI:mysql:database=".&ZM_DB_NAME.";host=".&ZM_DB_SERVER, &ZM_DB_USERA, &ZM_DB_PASSA ); + my $dbh = DBI->connect( "DBI:mysql:database=".&ZM_DB_NAME.";host=".&ZM_DB_SERVER, &ZM_DB_USER, &ZM_DB_PASS ); my $sql = "select * from Config"; my $sth = $dbh->prepare_cached( $sql ) or die( "Can't prepare '$sql': ".$dbh->errstr() ); @@ -94,7 +92,7 @@ my $command = $ARGV[0]; my $state; -my $dbh = DBI->connect( "DBI:mysql:database=".ZM_DB_NAME.";host=".ZM_DB_SERVER, ZM_DB_USERA, ZM_DB_PASSA ); +my $dbh = DBI->connect( "DBI:mysql:database=".ZM_DB_NAME.";host=".ZM_DB_SERVER, ZM_DB_USER, ZM_DB_PASS ); if ( !$command || $command !~ /^(?:start|stop|restart|status)$/ ) { diff --git a/scripts/zmupdate.pl.z b/scripts/zmupdate.pl.z index ba95fe5a1..bde8ad3af 100755 --- a/scripts/zmupdate.pl.z +++ b/scripts/zmupdate.pl.z @@ -44,16 +44,14 @@ BEGIN open( CONFIG, "<".ZM_CONFIG ) or die( "Can't open config file: $!" ); foreach my $str ( ) { - next if ( $str =~ /^\s*$/ ); - next if ( $str =~ /^\s*#/ ); - my ( $name, $value ) = $str =~ /^\s*([^=\s]+)\s*=\s*([^=\s]+)\s*$/; + 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_USERA' ) || - ( $name eq 'ZM_DB_PASSA' ) || - ( $name eq 'ZM_DB_USERB' ) || - ( $name eq 'ZM_DB_PASSB' )) + ( $name eq 'ZM_DB_USER' ) || + ( $name eq 'ZM_DB_PASS' )) { *{$name} = sub { $value }; } @@ -62,7 +60,7 @@ BEGIN use DBI; no strict 'refs'; - my $dbh = DBI->connect( "DBI:mysql:database=".&ZM_DB_NAME.";host=".&ZM_DB_SERVER, &ZM_DB_USERA, &ZM_DB_PASSA ); + my $dbh = DBI->connect( "DBI:mysql:database=".&ZM_DB_NAME.";host=".&ZM_DB_SERVER, &ZM_DB_USER, &ZM_DB_PASS ); my $sql = "select * from Config"; my $sth = $dbh->prepare_cached( $sql ) or die( "Can't prepare '$sql': ".$dbh->errstr() ); @@ -102,8 +100,8 @@ my $check = 0; my $rename = 0; my $zone_fix = 0; my $version = ''; -my $db_user = ZM_DB_USERA; -my $db_pass = ZM_DB_PASSA; +my $db_user = ZM_DB_USER; +my $db_pass = ZM_DB_PASS; sub Usage { print( " @@ -148,7 +146,7 @@ if ( $check ) print( "Update agent starting at ".strftime( '%y/%m/%d %H:%M:%S', localtime() )."\n" ); -my $dbh = DBI->connect( "DBI:mysql:database=".ZM_DB_NAME.";host=".ZM_DB_SERVER, ZM_DB_USERA, ZM_DB_PASSA ); +my $dbh = DBI->connect( "DBI:mysql:database=".ZM_DB_NAME.";host=".ZM_DB_SERVER, ZM_DB_USER, ZM_DB_PASS ); if ( $check && ZM_CHECK_FOR_UPDATES ) { @@ -236,7 +234,7 @@ if ( $zone_fix ) { require DBI; - my $dbh = DBI->connect( "DBI:mysql:database=".ZM_DB_NAME.";host=".ZM_DB_SERVER, ZM_DB_USERA, ZM_DB_PASSA ); + my $dbh = DBI->connect( "DBI:mysql:database=".ZM_DB_NAME.";host=".ZM_DB_SERVER, 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 $sth = $dbh->prepare_cached( $sql ) or die( "Can't prepare '$sql': ".$dbh->errstr() ); @@ -341,7 +339,7 @@ if ( $version ) # Rename the event directories and create a new symlink for the names chdir( EVENT_PATH ); - my $dbh = DBI->connect( "DBI:mysql:database=".ZM_DB_NAME.";host=".ZM_DB_SERVER, ZM_DB_USERA, ZM_DB_PASSA ); + my $dbh = DBI->connect( "DBI:mysql:database=".ZM_DB_NAME.";host=".ZM_DB_SERVER, ZM_DB_USER, ZM_DB_PASS ); my $sql = "select * from Monitors order by Id"; my $sth = $dbh->prepare_cached( $sql ) or die( "Can't prepare '$sql': ".$dbh->errstr() ); diff --git a/scripts/zmvideo.pl.z b/scripts/zmvideo.pl.z index f892455a5..c52c9434a 100644 --- a/scripts/zmvideo.pl.z +++ b/scripts/zmvideo.pl.z @@ -42,16 +42,14 @@ BEGIN open( CONFIG, "<".ZM_CONFIG ) or die( "Can't open config file: $!" ); foreach my $str ( ) { - next if ( $str =~ /^\s*$/ ); - next if ( $str =~ /^\s*#/ ); - my ( $name, $value ) = $str =~ /^\s*([^=\s]+)\s*=\s*([^=\s]+)\s*$/; + 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_USERA' ) || - ( $name eq 'ZM_DB_PASSA' ) || - ( $name eq 'ZM_DB_USERB' ) || - ( $name eq 'ZM_DB_PASSB' )) + ( $name eq 'ZM_DB_USER' ) || + ( $name eq 'ZM_DB_PASS' )) { *{$name} = sub { $value }; } @@ -60,7 +58,7 @@ BEGIN use DBI; no strict 'refs'; - my $dbh = DBI->connect( "DBI:mysql:database=".&ZM_DB_NAME.";host=".&ZM_DB_SERVER, &ZM_DB_USERB, &ZM_DB_PASSB ); + my $dbh = DBI->connect( "DBI:mysql:database=".&ZM_DB_NAME.";host=".&ZM_DB_SERVER, &ZM_DB_USER, &ZM_DB_PASS ); my $sql = "select * from Config"; my $sth = $dbh->prepare_cached( $sql ) or die( "Can't prepare '$sql': ".$dbh->errstr() ); @@ -159,7 +157,7 @@ open( STDERR, ">&LOG" ) || die( "Can't dup stderr: $!" ); select( STDERR ); $| = 1; select( LOG ); $| = 1; -my $dbh = DBI->connect( "DBI:mysql:database=".ZM_DB_NAME.";host=".ZM_DB_SERVER, ZM_DB_USERB, ZM_DB_PASSB ); +my $dbh = DBI->connect( "DBI:mysql:database=".ZM_DB_NAME.";host=".ZM_DB_SERVER, ZM_DB_USER, ZM_DB_PASS ); 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"; diff --git a/scripts/zmwatch.pl.z b/scripts/zmwatch.pl.z index 209fe0b0e..c8559a6f1 100755 --- a/scripts/zmwatch.pl.z +++ b/scripts/zmwatch.pl.z @@ -41,16 +41,14 @@ BEGIN open( CONFIG, "<".ZM_CONFIG ) or die( "Can't open config file: $!" ); foreach my $str ( ) { - next if ( $str =~ /^\s*$/ ); - next if ( $str =~ /^\s*#/ ); - my ( $name, $value ) = $str =~ /^\s*([^=\s]+)\s*=\s*([^=\s]+)\s*$/; + 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_USERA' ) || - ( $name eq 'ZM_DB_PASSA' ) || - ( $name eq 'ZM_DB_USERB' ) || - ( $name eq 'ZM_DB_PASSB' )) + ( $name eq 'ZM_DB_USER' ) || + ( $name eq 'ZM_DB_PASS' )) { *{$name} = sub { $value }; } @@ -59,7 +57,7 @@ BEGIN use DBI; no strict 'refs'; - my $dbh = DBI->connect( "DBI:mysql:database=".&ZM_DB_NAME.";host=".&ZM_DB_SERVER, &ZM_DB_USERA, &ZM_DB_PASSA ); + my $dbh = DBI->connect( "DBI:mysql:database=".&ZM_DB_NAME.";host=".&ZM_DB_SERVER, &ZM_DB_USER, &ZM_DB_PASS ); my $sql = "select * from Config"; my $sth = $dbh->prepare_cached( $sql ) or die( "Can't prepare '$sql': ".$dbh->errstr() ); @@ -111,7 +109,7 @@ print( "Watchdog starting at ".strftime( '%y/%m/%d %H:%M:%S', localtime() )."\n" print( "Watchdog pausing for ".START_DELAY." seconds\n" ); sleep( START_DELAY ); -my $dbh = DBI->connect( "DBI:mysql:database=".ZM_DB_NAME.";host=".ZM_DB_SERVER, ZM_DB_USERA, ZM_DB_PASSA ); +my $dbh = DBI->connect( "DBI:mysql:database=".ZM_DB_NAME.";host=".ZM_DB_SERVER, ZM_DB_USER, ZM_DB_PASS ); my $sql = "select * from Monitors"; my $sth = $dbh->prepare_cached( $sql ) or die( "Can't prepare '$sql': ".$dbh->errstr() ); diff --git a/scripts/zmx10.pl.z b/scripts/zmx10.pl.z index ffa7401be..3d95c3c45 100755 --- a/scripts/zmx10.pl.z +++ b/scripts/zmx10.pl.z @@ -40,16 +40,14 @@ BEGIN open( CONFIG, "<".ZM_CONFIG ) or die( "Can't open config file: $!" ); foreach my $str ( ) { - next if ( $str =~ /^\s*$/ ); - next if ( $str =~ /^\s*#/ ); - my ( $name, $value ) = $str =~ /^\s*([^=\s]+)\s*=\s*([^=\s]+)\s*$/; + 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_USERA' ) || - ( $name eq 'ZM_DB_PASSA' ) || - ( $name eq 'ZM_DB_USERB' ) || - ( $name eq 'ZM_DB_PASSB' )) + ( $name eq 'ZM_DB_USER' ) || + ( $name eq 'ZM_DB_PASS' )) { *{$name} = sub { $value }; } @@ -58,7 +56,7 @@ BEGIN use DBI; no strict 'refs'; - my $dbh = DBI->connect( "DBI:mysql:database=".&ZM_DB_NAME.";host=".&ZM_DB_SERVER, &ZM_DB_USERA, &ZM_DB_PASSA ); + my $dbh = DBI->connect( "DBI:mysql:database=".&ZM_DB_NAME.";host=".&ZM_DB_SERVER, &ZM_DB_USER, &ZM_DB_PASS ); my $sql = "select * from Config"; my $sth = $dbh->prepare_cached( $sql ) or die( "Can't prepare '$sql': ".$dbh->errstr() ); @@ -206,7 +204,7 @@ sub runServer bind( SERVER, $saddr ) or die( "Can't bind: $!" ); listen( SERVER, SOMAXCONN ) or die( "Can't listen: $!" ); - $dbh = DBI->connect( "DBI:mysql:database=".main::ZM_DB_NAME.";host=".main::ZM_DB_SERVER, main::ZM_DB_USERA, main::ZM_DB_PASSA ); + $dbh = DBI->connect( "DBI:mysql:database=".main::ZM_DB_NAME.";host=".main::ZM_DB_SERVER, main::ZM_DB_USER, main::ZM_DB_PASS ); $x10 = new X10::ActiveHome( port=>main::ZM_X10_DEVICE, house_code=>main::ZM_X10_HOUSE_CODE, debug=>1 ); diff --git a/src/zm_config.cpp b/src/zm_config.cpp index e5522faf4..d10cdf016 100644 --- a/src/zm_config.cpp +++ b/src/zm_config.cpp @@ -25,7 +25,7 @@ #include "zm_db.h" #include "zm_regexp.h" -char *ZM_DB_SERVER="", *ZM_DB_NAME="", *ZM_DB_USERA="", *ZM_DB_PASSA="", *ZM_DB_USERB="", *ZM_DB_PASSB=""; +char *ZM_DB_SERVER="", *ZM_DB_NAME="", *ZM_DB_USER="", *ZM_DB_PASS=""; void zmLoadConfig() { @@ -52,10 +52,8 @@ void zmLoadConfig() strncpy( val, keyval->MatchString( 2 ), keyval->MatchLength( 2 )); if (strcasecmp( keyval->MatchString( 1 ), "ZM_DB_SERVER" ) == 0 ) ZM_DB_SERVER = val; else if (strcasecmp( keyval->MatchString( 1 ), "ZM_DB_NAME" ) == 0 ) ZM_DB_NAME = val; - else if (strcasecmp( keyval->MatchString( 1 ), "ZM_DB_USERA" ) == 0 ) ZM_DB_USERA = val; - else if (strcasecmp( keyval->MatchString( 1 ), "ZM_DB_PASSA" ) == 0 ) ZM_DB_PASSA = val; - else if (strcasecmp( keyval->MatchString( 1 ), "ZM_DB_USERB" ) == 0 ) ZM_DB_USERB = val; - else if (strcasecmp( keyval->MatchString( 1 ), "ZM_DB_PASSB" ) == 0 ) ZM_DB_PASSB = val; + else if (strcasecmp( keyval->MatchString( 1 ), "ZM_DB_USER" ) == 0 ) ZM_DB_USER = val; + else if (strcasecmp( keyval->MatchString( 1 ), "ZM_DB_PASS" ) == 0 ) ZM_DB_PASS = val; else { Warning(( "Invalid parameter \"%s\" in %s", keyval->MatchString( 1 ), ZM_CONFIG )); diff --git a/src/zm_config.h.z b/src/zm_config.h.z index 49db3c44e..4a1348692 100644 --- a/src/zm_config.h.z +++ b/src/zm_config.h.z @@ -39,7 +39,7 @@ #define ZM_MAX_FPS 30 // The maximum frame rate we expect to handle #define ZM_SAMPLE_RATE int(1000000/ZM_MAX_FPS) // A general nyquist sample frequency for delays etc -extern char *ZM_DB_SERVER, *ZM_DB_NAME, *ZM_DB_USERA, *ZM_DB_PASSA, *ZM_DB_USERB, *ZM_DB_PASSB; +extern char *ZM_DB_SERVER, *ZM_DB_NAME, *ZM_DB_USER, *ZM_DB_PASS; extern void zmLoadConfig(); class ConfigItem diff --git a/src/zm_db.cpp b/src/zm_db.cpp index 732bbae11..a371528a8 100644 --- a/src/zm_db.cpp +++ b/src/zm_db.cpp @@ -24,14 +24,14 @@ MYSQL dbconn; -void zmDbConnect( const char *user, const char*pass ) +void zmDbConnect() { if ( !mysql_init( &dbconn ) ) { Error(( "Can't initialise structure: %s", mysql_error( &dbconn ) )); exit( mysql_errno( &dbconn ) ); } - if ( !mysql_real_connect( &dbconn, ZM_DB_SERVER, user, pass, 0, 0, 0, 0 ) ) + if ( !mysql_real_connect( &dbconn, ZM_DB_SERVER, ZM_DB_USER, ZM_DB_PASS, 0, 0, 0, 0 ) ) { Error(( "Can't connect to server: %s", mysql_error( &dbconn ) )); exit( mysql_errno( &dbconn ) ); diff --git a/src/zm_db.h b/src/zm_db.h index db2b5aad0..0c3faead4 100644 --- a/src/zm_db.h +++ b/src/zm_db.h @@ -26,6 +26,6 @@ extern MYSQL dbconn; -void zmDbConnect( const char *user, const char*pass ); +void zmDbConnect(); #endif // ZM_DB_H diff --git a/src/zma.cpp b/src/zma.cpp index 09f1ddf02..f302ce3a9 100644 --- a/src/zma.cpp +++ b/src/zma.cpp @@ -128,7 +128,7 @@ int main( int argc, char *argv[] ) zmLoadConfig(); - zmDbConnect( ZM_DB_USERA, ZM_DB_PASSA ); + zmDbConnect(); Monitor *monitor = Monitor::Load( id, true, Monitor::ANALYSIS ); diff --git a/src/zmc.cpp b/src/zmc.cpp index cace4d7d2..b863566d8 100644 --- a/src/zmc.cpp +++ b/src/zmc.cpp @@ -146,7 +146,7 @@ int main( int argc, char *argv[] ) zmLoadConfig(); - zmDbConnect( ZM_DB_USERA, ZM_DB_PASSA ); + zmDbConnect(); Monitor **monitors = 0; int n_monitors = 0; diff --git a/src/zmf.cpp b/src/zmf.cpp index b7000d190..742517078 100644 --- a/src/zmf.cpp +++ b/src/zmf.cpp @@ -195,7 +195,7 @@ int main( int argc, char *argv[] ) zmLoadConfig(); - zmDbConnect( ZM_DB_USERB, ZM_DB_PASSB ); + zmDbConnect(); Monitor *monitor = Monitor::Load( id, false ); diff --git a/src/zmfix.cpp b/src/zmfix.cpp index 3d5edb138..70dd732c8 100644 --- a/src/zmfix.cpp +++ b/src/zmfix.cpp @@ -110,7 +110,7 @@ int main( int argc, char *argv[] ) else { // Only do registered devices - zmDbConnect( ZM_DB_USERA, ZM_DB_PASSA ); + zmDbConnect(); static char sql[BUFSIZ]; //snprintf( sql, sizeof(sql), "select distinct Device from Monitors where Function != 'None' and Type = 'Local'" ); diff --git a/src/zms.cpp b/src/zms.cpp index 782d3f7f1..6e0e43ecc 100644 --- a/src/zms.cpp +++ b/src/zms.cpp @@ -92,7 +92,7 @@ int main( int argc, const char *argv[] ) } } - zmDbConnect( ZM_DB_USERA, ZM_DB_PASSA ); + zmDbConnect(); setbuf( stdout, 0 ); if ( nph ) diff --git a/src/zmu.cpp b/src/zmu.cpp index eaed87674..87406ff9b 100644 --- a/src/zmu.cpp +++ b/src/zmu.cpp @@ -353,7 +353,7 @@ int main( int argc, char *argv[] ) zmDbgInit(); zmLoadConfig(); - zmDbConnect( ZM_DB_USERB, ZM_DB_PASSB ); + zmDbConnect(); ValidateAccess( username, password, mon_id, function ); diff --git a/web/zm_config.php.z b/web/zm_config.php.z index 71cadfe04..1683223be 100644 --- a/web/zm_config.php.z +++ b/web/zm_config.php.z @@ -27,29 +27,26 @@ define( "ZM_PATH_WEB", "" ); // Path to web files define( "ZM_PATH_CGI", "" ); // Path to cgi files $cfg = fopen( ZM_CONFIG, "r") or die("Could not open config file."); -while ( !feof($cfg) ) { - $str = fgets( $cfg ); - if ( preg_match( '/^\s*$/', $str )) { continue; } - elseif ( preg_match( '/^\s*#/', $str )) { continue; } - elseif ( preg_match( '/^\s*([^=\s+)\s*=\s*([^=\s+)\s*$/', $str, $matches )) - { +while ( !feof($cfg) ) +{ + $str = fgets( $cfg ); + if ( preg_match( '/^\s*$/', $str )) { continue; } + elseif ( preg_match( '/^\s*#/', $str )) { continue; } + elseif ( preg_match( '/^\s*([^=\s+)\s*=\s*([^=\s+)\s*$/', $str, $matches )) + { if (( $matches[1] == "ZM_DB_SERVER") || ( $matches[1] == "ZM_DB_NAME") || - ( $matches[1] == "ZM_DB_USERA") || - ( $matches[1] == "ZM_DB_PASSA") || - ( $matches[1] == "ZM_DB_USERB") || - ( $matches[1] == "ZM_DB_PASSB")) + ( $matches[1] == "ZM_DB_USER") || + ( $matches[1] == "ZM_DB_PASS")) { - define( $matches[1], $matches[2] ); + define( $matches[1], $matches[2] ); } - } + } } fclose( $cfg ); // This section is options normally derived from other options or configuration // -define( "ZM_DB_USER", ZM_DB_USERA ); // Database login -define( "ZM_DB_PASS", ZM_DB_PASSA ); // Database password define( "ZMU_PATH", ZM_PATH_BIN."/zmu" ); // Local path to the ZoneMinder Utility // These are miscellaneous options you won't normally need to change diff --git a/zm.conf.z b/zm.conf.z index 6173e597b..aa1a6aa8d 100644 --- a/zm.conf.z +++ b/zm.conf.z @@ -1,8 +1,5 @@ # ZoneMinder config - ZM_DB_SERVER= ZM_DB_NAME= -ZM_DB_USERA= -ZM_DB_PASSA= -ZM_DB_USERB= -ZM_DB_PASSB= +ZM_DB_USER= +ZM_DB_PASS= diff --git a/zmconfig.pl.in b/zmconfig.pl.in index 73b84fbef..f5a3f9b03 100755 --- a/zmconfig.pl.in +++ b/zmconfig.pl.in @@ -181,34 +181,18 @@ my @options = category => 'core', }, { - name => "ZM_DB_USERA", + name => "ZM_DB_USER", default => "", - description => "Privileged DB user name, needs at least select, insert, update and delete privileges", - help => "This is the username of a MySQL user that has full privileges to select, insert, update and delete data from your ZoneMinder database. If you have no user available yet you can create one by typing 'mysql mysql' with additional parameters as required to give you access. Then at the prompt type 'grant select,insert,update,delete on .* to '' identified by '';'. Then type 'quit' to exit. You may also need to type 'mysqladmin reload' to ensure your changes take effect. Note that the username and passwords used here are not related to your Linux login or accounts and should not be the same.", + description => "DB user name, needs at least select, insert, update and delete privileges", + help => "This is the username of the MySQL user that has privileges to select, insert, update and delete data from your ZoneMinder database. If you have no user available yet you can create one by typing 'mysql mysql' with additional parameters as required to give you access. Then at the prompt type 'grant select,insert,update,delete on .* to '' identified by '';'. Then type 'quit' to exit. You may also need to type 'mysqladmin reload' to ensure your changes take effect. Note that the username and passwords used here are not related to your Linux login or accounts and should not be the same.", type => $types{alphanum}, category => 'core', }, { - name => "ZM_DB_PASSA", + name => "ZM_DB_PASS", default => "", - description => "Privileged DB user password", - help => "This is the password of a MySQL user that has full privileges to select, insert, update and delete data from your ZoneMinder database. If you have no user available yet you can create one by typing 'mysql mysql' with additional parameters as required to give you access. Then at the prompt type 'grant select,insert,update,delete on .* to '' identified by '';'. Then type 'quit' to exit. You may also need to type 'mysqladmin reload' to ensure your changes take effect. Note that the username and passwords used here are not related to your Linux login or accounts and should not be the same.", - type => $types{alphanum}, - category => 'core', - }, - { - name => "ZM_DB_USERB", - default => "", - description => "Unprivileged DB user name, need just select privilege.", - help => "This is the username of a MySQL user that has only privileges to select data from your ZoneMinder database and is used in cgi programs where full access is neither necessary or desiarable. If you have no user available yet you can create one by typing 'mysql mysql' with additional parameters as required to give you access. Then at the prompt type 'grant select on .* to '' identified by '';'. Then type 'quit' to exit. You may also need to type 'mysqladmin reload' to ensure your changes take effect. Note that the username and passwords used here are not related to your Linux login or accounts and should not be the same.", - type => $types{alphanum}, - category => 'core', - }, - { - name => "ZM_DB_PASSB", - default => "", - description => "Unprivileged DB user password", - help => "This is the password of a MySQL user that has only privileges to select data from your ZoneMinder database and is used in cgi programs where full access is neither necessary or desiarable. If you have no user available yet you can create one by typing 'mysql mysql' with additional parameters as required to give you access. Then at the prompt type 'grant select on .* to '' identified by '';'. Then type 'quit' to exit. You may also need to type 'mysqladmin reload' to ensure your changes take effect. Note that the username and passwords used here are not related to your Linux login or accounts and should not be the same.", + description => "DB user password", + help => "This is the password of the MySQL user that has privileges to select, insert, update and delete data from your ZoneMinder database. If you have no user available yet you can create one by typing 'mysql mysql' with additional parameters as required to give you access. Then at the prompt type 'grant select,insert,update,delete on .* to '' identified by '';'. Then type 'quit' to exit. You may also need to type 'mysqladmin reload' to ensure your changes take effect. Note that the username and passwords used here are not related to your Linux login or accounts and should not be the same.", type => $types{alphanum}, category => 'core', }, @@ -1485,7 +1469,7 @@ sub saveOptionsToFile sub saveOptionsToDB { print( "Saving config to DB\n" ); - my $dbh = DBI->connect( "DBI:mysql:database=".$options_hash{ZM_DB_NAME}->{value}.";host=".$options_hash{ZM_DB_SERVER}->{value}, $options_hash{ZM_DB_USERA}->{value}, $options_hash{ZM_DB_PASSA}->{value} ); + my $dbh = DBI->connect( "DBI:mysql:database=".$options_hash{ZM_DB_NAME}->{value}.";host=".$options_hash{ZM_DB_SERVER}->{value}, $options_hash{ZM_DB_USER}->{value}, $options_hash{ZM_DB_PASS}->{value} ); if ( !$dbh ) { @@ -1581,7 +1565,7 @@ sub loadOptionsFromFile sub loadOptionsFromDB { print( "Loading config from DB\n" ); - my $dbh = DBI->connect( "DBI:mysql:database=".$options_hash{ZM_DB_NAME}->{value}.";host=".$options_hash{ZM_DB_SERVER}->{value}, $options_hash{ZM_DB_USERA}->{value}, $options_hash{ZM_DB_PASSA}->{value} ); + my $dbh = DBI->connect( "DBI:mysql:database=".$options_hash{ZM_DB_NAME}->{value}.";host=".$options_hash{ZM_DB_SERVER}->{value}, $options_hash{ZM_DB_USER}->{value}, $options_hash{ZM_DB_PASS}->{value} ); if ( !$dbh ) {