2008-07-14 21:54:50 +08:00
< ? php
//
// ZoneMinder web configuration file, $Date$, $Revision$
2008-07-25 17:48:16 +08:00
// Copyright (C) 2001-2008 Philip Coombes
2008-07-14 21:54:50 +08:00
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
// as published by the Free Software Foundation; either version 2
// of the License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
2016-12-26 23:23:16 +08:00
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
2008-07-14 21:54:50 +08:00
//
//
// This section contains options substituted by the zmconfig.pl utility, do not edit these directly
//
define ( " ZM_CONFIG " , " @ZM_CONFIG@ " ); // Path to config file
2017-06-06 04:39:19 +08:00
define ( " ZM_CONFIG_SUBDIR " , " @ZM_CONFIG_SUBDIR@ " ); // Path to config subfolder
2013-11-01 21:47:28 +08:00
// Define, and override any given in config file
define ( " ZM_VERSION " , " @VERSION@ " ); // Version
2017-05-17 23:30:39 +08:00
define ( " ZM_DIR_TEMP " , " @ZM_TMPDIR@ " );
2008-07-14 21:54:50 +08:00
2011-06-21 17:19:10 +08:00
$configFile = ZM_CONFIG ;
$localConfigFile = basename ( $configFile );
2017-08-14 23:38:21 +08:00
if ( file_exists ( $localConfigFile ) && filesize ( $localConfigFile ) > 0 ) {
if ( php_sapi_name () == 'cli' && empty ( $_SERVER [ 'REMOTE_ADDR' ]) )
print ( " Warning, overriding installed $localConfigFile file with local copy \n " );
else
error_log ( " Warning, overriding installed $localConfigFile file with local copy " );
$configFile = $localConfigFile ;
2011-06-21 17:19:10 +08:00
}
2017-06-06 04:39:19 +08:00
# Process name, value pairs from the main config file first
$configvals = process_configfile ( $configFile );
# Search for user created config files. If one or more are found then
# update our config value array with those values
$configSubFolder = ZM_CONFIG_SUBDIR ;
if ( is_dir ( $configSubFolder ) ) {
2017-08-14 23:38:21 +08:00
if ( is_readable ( $configSubFolder ) ) {
foreach ( glob ( " $configSubFolder /*.conf " ) as $filename ) {
2017-10-07 23:31:48 +08:00
//error_log("processing $filename");
2017-08-14 23:38:21 +08:00
$configvals = array_replace ( $configvals , process_configfile ( $filename ) );
2017-06-06 04:39:19 +08:00
}
2017-08-14 23:38:21 +08:00
} else {
error_log ( " WARNING: ZoneMinder configuration subfolder found but is not readable. Check folder permissions on $configSubFolder . " );
}
2017-09-27 04:13:51 +08:00
} else {
error_log ( " WARNING: ZoneMinder configuration subfolder found but is not a directory. Check $configSubFolder . " );
2017-06-06 04:39:19 +08:00
}
# Now that our array our finalized, define each key => value
# pair in the array as a constant
foreach ( $configvals as $key => $value ) {
2017-08-14 23:38:21 +08:00
define ( $key , $value );
2008-07-14 21:54:50 +08:00
}
//
// This section is options normally derived from other options or configuration
//
define ( " ZMU_PATH " , ZM_PATH_BIN . " /zmu " ); // Local path to the ZoneMinder Utility
2008-10-28 22:25:12 +08:00
//
2011-02-16 05:59:06 +08:00
// If setup supports Video 4 Linux v2 and/or v1
2008-10-28 22:25:12 +08:00
//
2011-02-16 05:59:06 +08:00
define ( " ZM_HAS_V4L2 " , " @ZM_HAS_V4L2@ " ); // V4L2 support enabled
define ( " ZM_HAS_V4L1 " , " @ZM_HAS_V4L1@ " ); // V4L1 support enabled
define ( " ZM_HAS_V4L " , " @ZM_HAS_V4L@ " ); // V4L support enabled
2008-10-28 22:25:12 +08:00
2015-02-22 01:12:07 +08:00
//
// If ONVIF support has been built in
//
define ( " ZM_HAS_ONVIF " , " @ZM_HAS_ONVIF@ " ); // ONVIF support enabled
2008-12-06 02:41:14 +08:00
//
// If PCRE dev libraries are installed
//
define ( " ZM_PCRE " , " @ZM_PCRE@ " ); // PCRE support enabled
2008-07-14 21:54:50 +08:00
//
// Alarm states
//
define ( " STATE_IDLE " , 0 );
define ( " STATE_PREALARM " , 1 );
define ( " STATE_ALARM " , 2 );
define ( " STATE_ALERT " , 3 );
define ( " STATE_TAPE " , 4 );
//
// DVR Control Commands
//
define ( " MSG_CMD " , 1 );
define ( " MSG_DATA_WATCH " , 2 );
define ( " MSG_DATA_EVENT " , 3 );
define ( " CMD_NONE " , 0 );
define ( " CMD_PAUSE " , 1 );
define ( " CMD_PLAY " , 2 );
define ( " CMD_STOP " , 3 );
define ( " CMD_FASTFWD " , 4 );
define ( " CMD_SLOWFWD " , 5 );
define ( " CMD_SLOWREV " , 6 );
define ( " CMD_FASTREV " , 7 );
define ( " CMD_ZOOMIN " , 8 );
define ( " CMD_ZOOMOUT " , 9 );
define ( " CMD_PAN " , 10 );
define ( " CMD_SCALE " , 11 );
define ( " CMD_PREV " , 12 );
define ( " CMD_NEXT " , 13 );
define ( " CMD_SEEK " , 14 );
2008-11-03 21:16:47 +08:00
define ( " CMD_VARPLAY " , 15 );
2016-04-11 04:33:55 +08:00
define ( " CMD_QUIT " , 17 );
2008-07-14 21:54:50 +08:00
define ( " CMD_QUERY " , 99 );
//
// These are miscellaneous options you won't normally need to change
//
define ( " MAX_EVENTS " , 10 ); // The maximum number of events to show in the monitor event listing
define ( " RATE_BASE " , 100 ); // The additional scaling factor used to help get fractional rates in integer format
define ( " SCALE_BASE " , 100 ); // The additional scaling factor used to help get fractional scales in integer format
//
2014-02-26 23:14:04 +08:00
// Date and time formats, not to be modified by language files
2008-07-14 21:54:50 +08:00
//
2014-02-26 23:14:04 +08:00
define ( " STRF_FMT_DATETIME_DB " , " %Y-%m-%d %H:%M:%S " ); // Strftime format for database queries, don't change
define ( " MYSQL_FMT_DATETIME_SHORT " , " %y/%m/%d %H:%i:%S " ); // MySQL date_format shorter format for dates with time
2008-07-14 21:54:50 +08:00
require_once ( 'database.php' );
loadConfig ();
$GLOBALS [ 'defaultUser' ] = array (
2017-12-05 00:05:50 +08:00
'Username' => " admin " ,
'Password' => " " ,
'Language' => " " ,
'Enabled' => 1 ,
'Stream' => 'View' ,
'Events' => 'Edit' ,
'Control' => 'Edit' ,
'Monitors' => 'Edit' ,
'Groups' => 'Edit' ,
'Devices' => 'Edit' ,
'System' => 'Edit' ,
'MaxBandwidth' => '' ,
'MonitorIds' => false
2008-07-14 21:54:50 +08:00
);
2017-08-14 23:38:21 +08:00
function loadConfig ( $defineConsts = true ) {
global $config ;
global $configCats ;
global $dbConn ;
$config = array ();
$configCat = array ();
$result = $dbConn -> query ( 'select * from Config order by Id asc' );
if ( ! $result )
echo mysql_error ();
$monitors = array ();
while ( $row = dbFetchNext ( $result ) ) {
if ( $defineConsts )
define ( $row [ 'Name' ], $row [ 'Value' ] );
$config [ $row [ 'Name' ]] = $row ;
if ( ! ( $configCat = & $configCats [ $row [ 'Category' ]]) ) {
$configCats [ $row [ 'Category' ]] = array ();
$configCat = & $configCats [ $row [ 'Category' ]];
2008-07-14 21:54:50 +08:00
}
2017-08-14 23:38:21 +08:00
$configCat [ $row [ 'Name' ]] = $row ;
}
//print_r( $config );
//print_r( $configCats );
2008-07-14 21:54:50 +08:00
}
2015-09-15 03:57:22 +08:00
require_once ( 'logger.php' );
2017-12-05 04:52:16 +08:00
// For Human-readability, use ZM_SERVER_HOST or ZM_SERVER_NAME in zm.conf, and convert it here to a ZM_SERVER_ID
2015-07-17 22:12:44 +08:00
if ( ! defined ( 'ZM_SERVER_ID' ) ) {
2017-08-14 23:38:21 +08:00
if ( defined ( 'ZM_SERVER_NAME' ) and ZM_SERVER_NAME ) {
$server_id = dbFetchOne ( 'SELECT Id FROM Servers WHERE Name=?' , 'Id' , array ( ZM_SERVER_NAME ));
if ( ! $server_id ) {
Error ( " Invalid Multi-Server configration detected. ZM_SERVER_NAME set to " . ZM_SERVER_NAME . " in zm.conf, but no corresponding entry found in Servers table. " );
} else {
define ( 'ZM_SERVER_ID' , $server_id );
}
} else if ( defined ( 'ZM_SERVER_HOST' ) and ZM_SERVER_HOST ) {
$server_id = dbFetchOne ( 'SELECT Id FROM Servers WHERE Name=?' , 'Id' , array ( ZM_SERVER_HOST ));
if ( ! $server_id ) {
Error ( " Invalid Multi-Server configration detected. ZM_SERVER_HOST set to " . ZM_SERVER_HOST . " in zm.conf, but no corresponding entry found in Servers table. " );
} else {
define ( 'ZM_SERVER_ID' , $server_id );
}
}
2015-07-09 23:45:19 +08:00
}
2017-06-06 04:39:19 +08:00
function process_configfile ( $configFile ) {
2017-08-14 23:38:21 +08:00
if ( is_readable ( $configFile ) ) {
$configvals = array ();
2017-08-22 21:52:14 +08:00
$cfg = fopen ( $configFile , 'r' ) or Error ( " Could not open config file: $configFile . " );
2017-08-14 23:38:21 +08:00
while ( ! feof ( $cfg ) ) {
$str = fgets ( $cfg , 256 );
if ( preg_match ( '/^\s*$/' , $str ))
continue ;
elseif ( preg_match ( '/^\s*#/' , $str ))
continue ;
elseif ( preg_match ( '/^\s*([^=\s]+)\s*=\s*(.*?)\s*$/' , $str , $matches ))
$configvals [ $matches [ 1 ]] = $matches [ 2 ];
2017-06-06 04:39:19 +08:00
}
2017-08-14 23:38:21 +08:00
fclose ( $cfg );
return ( $configvals );
} else {
error_log ( " WARNING: ZoneMinder configuration file found but is not readable. Check file permissions on $configFile . " );
return ( false );
}
2017-06-06 04:39:19 +08:00
}
2015-07-09 23:45:19 +08:00
2008-07-14 21:54:50 +08:00
?>