From 45db266ede1036b79823298cc7bd6239954e885d Mon Sep 17 00:00:00 2001 From: Isaac Connor Date: Sat, 22 Jan 2022 12:07:12 -0500 Subject: [PATCH 1/6] Put full config available to javascript --- web/skins/classic/js/skin.js.php | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/web/skins/classic/js/skin.js.php b/web/skins/classic/js/skin.js.php index 2b7980c3a..6cde755b6 100644 --- a/web/skins/classic/js/skin.js.php +++ b/web/skins/classic/js/skin.js.php @@ -105,3 +105,10 @@ stateStrings[STATE_PREALARM] = ""; stateStrings[STATE_ALARM] = ""; stateStrings[STATE_ALERT] = ""; stateStrings[STATE_TAPE] = ""; + +$c) { + echo $name . ' = \''.$c['Value'].'\''.PHP_EOL; +} +?> From 35efb111ac2f264387d999cbac7adb98451787d1 Mon Sep 17 00:00:00 2001 From: Isaac Connor Date: Sat, 22 Jan 2022 12:30:59 -0500 Subject: [PATCH 2/6] Add Private to Config --- db/zm_create.sql.in | 1 + db/zm_update-1.37.10.sql | 20 +++++++++++++++++++ .../ZoneMinder/lib/ZoneMinder/Config.pm.in | 5 +++-- .../lib/ZoneMinder/ConfigData.pm.in | 3 +++ 4 files changed, 27 insertions(+), 2 deletions(-) create mode 100644 db/zm_update-1.37.10.sql diff --git a/db/zm_create.sql.in b/db/zm_create.sql.in index db72cb58d..7dc77cc47 100644 --- a/db/zm_create.sql.in +++ b/db/zm_create.sql.in @@ -39,6 +39,7 @@ CREATE TABLE `Config` ( `Help` text, `Category` varchar(32) NOT NULL default '', `Readonly` tinyint(3) unsigned NOT NULL default '0', + `Private` BOOLEAN NOT NULL DEFAULT FALSE, `Requires` text, PRIMARY KEY (`Name`) ) ENGINE=@ZM_MYSQL_ENGINE@; diff --git a/db/zm_update-1.37.10.sql b/db/zm_update-1.37.10.sql new file mode 100644 index 000000000..30c2d8766 --- /dev/null +++ b/db/zm_update-1.37.10.sql @@ -0,0 +1,20 @@ +-- +-- Update Config table to have Private +-- + +SELECT 'Checking for Private in Config'; +SET @s = (SELECT IF( + (SELECT COUNT(*) + FROM INFORMATION_SCHEMA.COLUMNS + WHERE table_name = 'Config' + AND table_schema = DATABASE() + AND column_name = 'Private' + ) > 0, +"SELECT 'Column Private already exists in Config'", +"ALTER TABLE `Config` ADD COLUMN `Private` BOOLEAN NOT NULL DEFAULT FALSE AFTER `Readonly`" +)); + +PREPARE stmt FROM @s; +EXECUTE stmt; + + diff --git a/scripts/ZoneMinder/lib/ZoneMinder/Config.pm.in b/scripts/ZoneMinder/lib/ZoneMinder/Config.pm.in index 21f9a2d02..849ec5450 100644 --- a/scripts/ZoneMinder/lib/ZoneMinder/Config.pm.in +++ b/scripts/ZoneMinder/lib/ZoneMinder/Config.pm.in @@ -156,7 +156,7 @@ sub loadConfigFromDB { print("Error: unable to load options from database: $DBI::errstr\n"); return(0); } - my $sql = "select * from Config"; + my $sql = 'SELECT * FROM Config'; my $sth = $dbh->prepare_cached( $sql ) or croak( "Can't prepare '$sql': ".$dbh->errstr() ); my $res = $sth->execute() @@ -203,7 +203,7 @@ sub saveConfigToDB { my $res = $dbh->do( $sql ) or croak( "Can't do '$sql': ".$dbh->errstr() ); - $sql = "replace into Config set Id = ?, Name = ?, Value = ?, Type = ?, DefaultValue = ?, Hint = ?, Pattern = ?, Format = ?, Prompt = ?, Help = ?, Category = ?, Readonly = ?, Requires = ?"; + $sql = "replace into Config set Id = ?, Name = ?, Value = ?, Type = ?, DefaultValue = ?, Hint = ?, Pattern = ?, Format = ?, Prompt = ?, Help = ?, Category = ?, Readonly = ?, Private = ?, Requires = ?"; my $sth = $dbh->prepare_cached( $sql ) or croak( "Can't prepare '$sql': ".$dbh->errstr() ); foreach my $option ( @options ) { @@ -240,6 +240,7 @@ sub saveConfigToDB { $option->{help}, $option->{category}, $option->{readonly} ? 1 : 0, + $option->{private} ? 1 : 0, $option->{db_requires} ) or croak("Can't execute when updating config entry $$option{name}: ".$sth->errstr() ); } # end foreach option diff --git a/scripts/ZoneMinder/lib/ZoneMinder/ConfigData.pm.in b/scripts/ZoneMinder/lib/ZoneMinder/ConfigData.pm.in index 48d494614..d9d3c5306 100644 --- a/scripts/ZoneMinder/lib/ZoneMinder/ConfigData.pm.in +++ b/scripts/ZoneMinder/lib/ZoneMinder/ConfigData.pm.in @@ -304,6 +304,7 @@ our @options = ( { name=>'ZM_AUTH_RELAY', value=>'hashed' } ], type => $types{string}, + private => 1, category => 'system', }, { @@ -462,6 +463,7 @@ our @options = ( {name=>'ZM_OPT_USE_GOOG_RECAPTCHA', value=>'yes'} ], type => $types{string}, + private => 1, category => 'system', }, { @@ -477,6 +479,7 @@ our @options = ( {name=>'ZM_OPT_USE_GOOG_RECAPTCHA', value=>'yes'} ], type => $types{string}, + private => 1, category => 'system', }, { From ce2d605b3d0eaa498ddc51a2b09e38a07623f57e Mon Sep 17 00:00:00 2001 From: Isaac Connor Date: Sat, 22 Jan 2022 12:31:15 -0500 Subject: [PATCH 3/6] load Private as well as Name,Value from Config --- web/includes/config.php.in | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/web/includes/config.php.in b/web/includes/config.php.in index b30aebdea..c463a14ae 100644 --- a/web/includes/config.php.in +++ b/web/includes/config.php.in @@ -165,7 +165,7 @@ function loadConfig( $defineConsts=true ) { $config = array(); - $result = $dbConn->query('SELECT Name,Value FROM Config'); + $result = $dbConn->query('SELECT Name,Value,Private FROM Config'); if ( !$result ) echo mysql_error(); while( $row = dbFetchNext($result) ) { From 3a0b88c013709a1336b8e86c0d3ab83f06ed6a5f Mon Sep 17 00:00:00 2001 From: Isaac Connor Date: Sat, 22 Jan 2022 12:31:36 -0500 Subject: [PATCH 4/6] Don't make private config entries available to js land. --- web/skins/classic/js/skin.js.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/web/skins/classic/js/skin.js.php b/web/skins/classic/js/skin.js.php index 6cde755b6..336c0a352 100644 --- a/web/skins/classic/js/skin.js.php +++ b/web/skins/classic/js/skin.js.php @@ -109,6 +109,7 @@ stateStrings[STATE_TAPE] = ""; $c) { - echo $name . ' = \''.$c['Value'].'\''.PHP_EOL; + if (!$c['Private']) + echo $name . ' = \''.$c['Value'].'\''.PHP_EOL; } ?> From 47aa1d1913319d47a540efe98147077b7717612e Mon Sep 17 00:00:00 2001 From: Isaac Connor Date: Sat, 22 Jan 2022 12:31:56 -0500 Subject: [PATCH 5/6] Bump version to 1.37.10 --- distros/redhat/zoneminder.spec | 2 +- version | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/distros/redhat/zoneminder.spec b/distros/redhat/zoneminder.spec index 16b8efb7e..b95d80626 100644 --- a/distros/redhat/zoneminder.spec +++ b/distros/redhat/zoneminder.spec @@ -36,7 +36,7 @@ %global _hardened_build 1 Name: zoneminder -Version: 1.37.9 +Version: 1.37.10 Release: 1%{?dist} Summary: A camera monitoring and analysis tool Group: System Environment/Daemons diff --git a/version b/version index 938adc6f6..a9009bf2a 100644 --- a/version +++ b/version @@ -1 +1 @@ -1.37.9 +1.37.10 From 90f75dae93214bf0f9300183cfb855f87d662445 Mon Sep 17 00:00:00 2001 From: Isaac Connor Date: Sat, 22 Jan 2022 12:33:48 -0500 Subject: [PATCH 6/6] Make config entries const --- web/skins/classic/js/skin.js.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/web/skins/classic/js/skin.js.php b/web/skins/classic/js/skin.js.php index 336c0a352..2d443fbe1 100644 --- a/web/skins/classic/js/skin.js.php +++ b/web/skins/classic/js/skin.js.php @@ -110,6 +110,6 @@ stateStrings[STATE_TAPE] = ""; global $config; foreach ($config as $name=>$c) { if (!$c['Private']) - echo $name . ' = \''.$c['Value'].'\''.PHP_EOL; + echo 'const '. $name . ' = \''.$c['Value'].'\''.PHP_EOL; } ?>